So I have a table that with ID values and dates that looks something like this:
ID Date
0001 1/1/2012
0002 1/2/2010
0002 1/2/2011
0001 1/1/2011
0001 1/1/2010
0002 1/2/2012
Basically, the ID values are unique to that year only - they reset the subsequent year.
I want to be able to sort by ID values and by dates, but I want to do the sorting so that the values are ordered by year. Just a regular sort of ID with a secondary date sort yields this:
ID Date
0001 1/1/2010
0001 1/1/2011
0001 1/1/2012
0002 1/2/2010
0002 1/2/2011
0002 1/2/2012
But I would like a query that generates a table that looks like this:
ID Date
0001 1/1/2010
0002 1/2/2010
0001 1/1/2011
0002 1/2/2011
0001 1/1/2012
0002 1/2/2012
Is this possible?
How about this:
order by year(date), id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With