I have following query which i need the count of the number of user who has the same golddate as the same day, however since i have to use the GROUP BY it doesnt return the zero values when there is no one on that day, can you please help ?
SELECT count( * ) AS total, DATE( `golddate` ) AS gold_date
FROM `user`
WHERE YEAR( `golddate` ) >=2014
GROUP BY DATE( `golddate` )
ORDER BY DATE( `golddate` ) ASC
I want to show something like
goldate | total
2012-12-10 | 23
2012-10-12 | 0
but issue is it never returns the zero value dates, due to the group by
I tried following but no use,
SELECT
u1.golddate
-- this will count the number of links to each word
-- if there are no links the COUNT() call will return 0
, COUNT(u2.golddate) AS linkCount
FROM user u2
LEFT JOIN user u1
ON u1.user_id = u2.user_id
OR u2.user_id = u1.user_id
GROUP BY u1.golddate
Nor even this doesnt work
SELECT COALESCE(COUNT(`golddate`), 0) AS total, DATE( `golddate` ) AS gold_count
FROM `user`
WHERE YEAR( `golddate` ) >=2014
GROUP BY DATE( `golddate` )
ORDER BY DATE( `golddate` ) ASC