My SQL database looks like this
ID DATE
1 2017-01-01
1 2017-01-03
1 2017-01-05
2 2017-01-06
2 2017-01-07
2 2017-01-08
2 2017-01-11
3 2017-01-11
How can I retrieve the Max(DATE) and second latest date for each ID as in below.
ID MAXDATE SECONDMAXDATE
1 2017-01-05 2017-01-03
2 2017-01-11 2017-01-08
3 2017-01-11 2017-01-11 (or 'NONE')
PS: when there is only 1 record, SECONDMAXDATE can display either the MAXDATE or a STRING (eg. NONE)