Reputation: 845
$SQLString = "SELECT
count(score) as counts,
DATE(date),
SUM(CASE WHEN gender = 1 then 1 ELSE 0 END) Male,
SUM(CASE WHEN gender = 2 then 1 ELSE 0 END) Female,
AVG(age) as age, score
FROM persons
WHERE date > '".$_SESSION['date1']."' AND date < '".$_SESSION['date2']."'
GROUP BY DATE(date)
ORDER BY DATE(date) asc";
This is my Query that display some data, like gender,age, etc per day. How could I aggregate those dates by months or years and display the added data?
Notice me if Im not explain my self as well :)
Upvotes: 3
Views: 3483