How do you sum the max values of each day using a query mysql The one below I at
ID: 3696500 • Letter: H
Question
How do you sum the max values of each day using a query mysql The one below I attempted is not working
SELECT DATE_FORMAT(orderDate,'%W, %M %e, %Y') orderDate, SUM(Count) sumCount
FROM
(
SELECT DATE_FORMAT(orderDate,'%M %e, %Y') orderDate, MAX(Count) AS maxCount
FROM testLocation
WHERE orderDate >= '$data1' AND orderDate < '$data2' + INTERVAL 1 DAY
)
GROUP BY MONTH(orderDate)
Explanation / Answer
Here in this case you have used to do the group by on the bases of month only, but in group by also add the date as well as given below:
GROUP BY DATE(orderDate), MONTH(orderDate)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.