Group By Date Part

To group by date part, use the GROUP BY clause and the EXTRACT() function. Pass EXTRACT() the date parts to isolate.

SELECT EXTRACT(YEAR FROM CloseDate) AS CloseDate_Year, EXTRACT(MONTH FROM CloseDate) AS CloseDate_Month, count(*) AS cnt
FROM "OpportunityFiscalEMTimezoned"
GROUP BY EXTRACT(YEAR FROM CloseDate), EXTRACT(MONTH FROM CloseDate)
LIMIT 10;

The results are grouped by year and month parts of the CloseDate field.

CloseDate_Year CloseDate_Month cnt
2014 12 1
2015 1 3
2015 2 1
2015 3 2
2015 4 2
2015 5 2
2015 6 1
2015 8 1
2015 10 1
2015 11 1