I'm Trying to select a datetime with a specific year from the table and display the amount of those dates that have that year.
I can select just the year from the datetime, but it gives me the amount of every single specific date, not just the year. Like:
| Date | Amount |
| 2012-04-07 | 5 |
| 2012-05-21 | 5 |
but I just want 2012, 10
.
Select YEAR(Orderdate), count(*)
From Orders
Group by Orderdate
The output needs to show a single row with 2012 in one column, and the total count of 2012's in the second column. Like this:
| Year | Amount |
| 2012 | 10 |
| 2013 | 8 |
| 2014 | 2 |