MySQL Forums
Forum List  »  Newbie

Multiple SELECT with multiple WHERE
Posted by: Gary Ehrenfeld
Date: August 24, 2018 04:33AM

This is not working. Not a master at SQL so could use some help.

SELECT
AVG(reading) AS overall,
AVG(reading) AS 7DAY WHERE (readdate >= CURDATE() - INTERVAL 7 DAY) AND (reading > 0) AND (readdate < CURDATE() + INTERVAL 7 DAY),
AVG(reading) AS 14DAY WHERE (readdate >= CURDATE() - INTERVAL 14 DAY) AND (reading > 0) AND (readdate < CURDATE() + INTERVAL 14 DAY)
FROM meter

I want to display this in a Dashboard Panel as 7 Day Average, 14 Day Average, Overall Average.

Options: ReplyQuote


Subject
Written By
Posted
Multiple SELECT with multiple WHERE
August 24, 2018 04:33AM


Sorry, only registered users may post in this forum.

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.