I'm looking for a query that can give me the latest (most current) date that is less than a specified date for each person. I found a query in thread that seems to do this, however, I was only able to get it to provide only one record rather than 2,356 records (distinct ids), so obviously, I misunderstood how to apply it.
Here is the query modified for our table name:
Here are some sample data:
[tt]
Row# ID Period Apno DecNo DecDate Dec
1 44219 Fall 2008 1 1 12/18/2007 12:00 FX
2 44219 Fall 2008 1 2 2/28/2008 13:09 WL
3 44219 Fall 2008 1 3 3/10/2008 10:12 CC
4 44206 Fall 2008 2 1 7/2/2008 23:56 CC
5 44206 Fall 2008 2 2 3/16/2008 11:30 WA
6 44103 Fall 2008 1 1 7/21/2008 14:35 CC
[/tt]
Based on the criteria, I would like to return rows 3 and 5 as these fall within the date specified.
Here is the query modified for our table name:
Code:
SELECT * FROM (
Select *
from mst_admissions_decision decision
Where decision.person_uid = person_uid
And decision_date is not null
and decision.decision_date <= '01-MAY-2008'
ORDER BY decision.decision_date DESC)
WHERE rownum = 1;
Here are some sample data:
[tt]
Row# ID Period Apno DecNo DecDate Dec
1 44219 Fall 2008 1 1 12/18/2007 12:00 FX
2 44219 Fall 2008 1 2 2/28/2008 13:09 WL
3 44219 Fall 2008 1 3 3/10/2008 10:12 CC
4 44206 Fall 2008 2 1 7/2/2008 23:56 CC
5 44206 Fall 2008 2 2 3/16/2008 11:30 WA
6 44103 Fall 2008 1 1 7/21/2008 14:35 CC
[/tt]
Based on the criteria, I would like to return rows 3 and 5 as these fall within the date specified.