Short and simple, I want to get a list of unique hours and their count representative.
SELECT DISTINCT(date_trunc('hour', occurred)) as time, COUNT(*)
FROM log
WHERE occurred BETWEEN '2014-01-01 00:00' AND '2014-01-01 23:59'
GROUP BY occurred;
This doesn't work, because I get way more results than 24.
So I went ahead and tried:
SELECT DISTINCT(occurred), COUNT(*)
FROM log
WHERE occurred BETWEEN .. AND ..
GROUP BY date_trunc('hour', occurred);
This is a invalid syntax and obviously me just winging it, hence I need help. How would one go about solving this?