Order By Date Part
To order by date part, use EXTRACT() on the date field with the ORDER BY clause. The query returns the count of rows containing these same values and orders the results by count descending.
| CloseDate_Year | CloseDate_Month | cnt |
|---|---|---|
| 2015 | 1 | 3 |
| 2015 | 3 | 2 |
| 2015 | 4 | 2 |
| 2015 | 5 | 2 |
| 2014 | 12 | 1 |
| 2015 | 2 | 1 |
| 2015 | 6 | 1 |
| 2015 | 8 | 1 |
| 2015 | 10 | 1 |
| 2015 | 11 | 1 |