var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: how to query second latest date??
i have a record with different dates
10/31/2003 2:48:48 PM , 123456
1/7/2004 8:23:58 AM, 123456
9/23/2004 8:16:26 PM, 123456
9/13/2004 2:48:10 PM, 123456
5/7/2004 10:30:57 AM, 123456
SELECT MAX(created) AS recent, num
GROUP BY num
this will give: 9/23/2004 8:16:26 PM, 123456
what is the sql to get: 9/13/2004 2:48:10 PM,123456
note that i cant delete the latest record from that list, and then get the max date again, because some records have only one occurance (one date). that record will be lost.
Would this be OK?
SELECT created, num
FROM (SELECT created, num, RANK() OVER (ORDER BY created DESC) rnk
FROM your_table) tab1
WHERE rnk = 2;