Find next most recent date

From: Chaihana Joe <ian_at_chezburns.com>
Date: Fri, 4 Jan 2008 01:18:15 -0800 (PST)
Message-ID: <2efafe60-d746-4495-b58f-80569ad79f39@q39g2000hsf.googlegroups.com>


Good morning.

I have a table with a date column. I want to find the next latest date in the data in that table.

I have got this far:

SELECT SNAPSHOT_DATE, ROWNUM
FROM (SELECT DISTINCT SNAPSHOT_DATE FROM MONTHLY_SNAPSHOTS     ORDER BY SNAPSHOT_DATE DESC ) WHERE ROWNUM > 0 which returns all the dates in the table.

If I change the where clause to WHERE ROWNUM = 1 I just get the most recent date.

But if I change the where clause to WHERE ROWNUM = 2 I get an empty recordset.

I seem to be missing something. Received on Fri Jan 04 2008 - 03:18:15 CST

Original text of this message