MySQL Forums
Forum List  »  Spanish

Re: Ayuda con query para obtener cuenta y promedio de misma columna
Posted by: Adan Santillan
Date: November 06, 2018 12:48PM

Hola Daniel,

Has intentado con algún query como el siguiente:

SELECT AN.ANIMAL
,AN.CANTIDAD
,(SELECT AN.CANTIDAD/( SELECT DAYS FROM "AQUI VA LAS TABLAS/JOINS DE TU QUERY" WHERE AN.ANIMAL= "ALGÚN CAMPO EN COMÚN CON TUS TABLAS") AS MEDIA

FROM ( SELECT ANIMAL
,COUNT(ANIMAL) as CANTIDAD
FROM animales
WHERE DATE(FECHA)=CURDATE()
) AS AN


En teoría, lo que necesitas son los animales del día actual, y para sacar la media, necesitas esa cantidad entre la cantidad de día, por animal.

Revisa mi sugerencia, tal vez no sea exacta, pero te dé alguna idea.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Ayuda con query para obtener cuenta y promedio de misma columna
304
November 06, 2018 12:48PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.