I'm trying to do a count of hits per day. The query does the counts as needed, however my days are not in order. How can I fix this?
hittime not converted is a timestamp -2016-06-16 06:57:14
Here's the query:
select to_char(hittime, 'YYYY-MM-DD'),
count(hitid)
from hits
group by to_char(hittime, 'YYYY-MM-DD');
Sample output:
to_char | count
------------+-------
2016-05-04 | 92
2016-05-05 | 120
2016-05-07 | 2
2016-05-08 | 2
2016-05-11 | 139
2016-05-13 | 54
2016-05-17 | 96
2016-05-18 | 23
2016-05-26 | 53
2016-05-28 | 1
2016-05-30 | 31
2016-06-04 | 9
2016-06-05 | 37
2016-06-06 | 173
2016-06-09 | 364
2016-06-13 | 446
2016-06-14 | 533
2016-06-16 | 10
2016-05-06 | 153
2016-05-09 | 297
2016-05-10 | 90
2016-05-12 | 88
2016-05-16 | 66
2016-05-19 | 123
2016-05-20 | 34
Aucun commentaire:
Enregistrer un commentaire