Need to get max date for each year from list of arbitrary dates:

date         year
1/10/2013    2013
3/26/2013    2013
4/20/2012    2012
9/10/2012    2012
5/6/2011     2011

So with a working query, using the above data, the correct result would be:

maxdate     year
3/26/2013    2013
9/10/2012    2012
5/6/2011     2011

Our database is proprietary, supporting only ANSI-SQL, no fancy extensions. Tried using group_by, but it's retrieving all dates for each year, not what I want.

1 Answer 1


It is possible that I am missing something, but you should be able to get the result easily using the max() aggregate and a GROUP BY:

  max(date) maxdate,
from yourtable
group by year;

See SQL Fiddle with Demo

  • I was grouping by date, that was the issue, ty.
    – Raffian
    Dec 10, 2013 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.