I have a table with columns: FILING_ID
, DATE
, and BLAH
I'm trying to write a query that for each FILING_ID
, returns the rows with the last three dates. If table is:
FILING_ID DATE
aksjdfj 2/1/2006
b 2/1/2006
b 3/1/2006
b 4/1/2006
b 5/1/2006
I would like:
FILING_ID DATE
aksjdfj 2/1/2006
b 3/1/2006
b 4/1/2006
b 5/1/2006
I was thinking of maybe running some query to figure out the 3rd highest date for each FILING_ID
then doing a join and comparing the cutoff date with the DATE
?
I use PostgreSQL. Is there some way to use limit?