I want my query to show all months grouped together, regardless of the year. For example, I would want this to be the output:
01/13/2015
01/01/2016
02/07/2015
02/01/2016
This is sample DDL - what must I alter so months are all displayed together regardless of year?
CREATE TABLE randomdate(dateofwork timestamp);
INSERT INTO randomdate VALUES('2016-01-01 00:00:00-05');
INSERT INTO randomdate VALUES('2015-01-13 00:00:00-05');
INSERT INTO randomdate VALUES('2016-02-01 00:00:00-05');
INSERT INTO randomdate VALUES('2015-02-07 00:00:00-05');
Select
date_trunc('month',randomdate)
from randomdate
GROUP BY date_trunc('month', randomdate)
ORDER BY date_trunc('month', randomdate) ASC