I have a feeling that this should be a simple query, but I'm having a brain fart or something and can't figure out how to do it.
I have a table called movement, which has two fields called mov_end_dt and mov_org_cd. The mov_org_cd has multiple records in the table and I want to pick out the one that either has a null value in the mov_end_dt or has the latest date in that field.
For instance, say the data in the table is:
The query should return 3/1/2008 for A00001 and NULL for A00002.Code:mov_org_cd mov_org_dt A00001 1/1/2008 A00001 2/1/2008 A00001 3/1/2008 A00002 4/1/2008 A00002 5/1/2008 A00002 NULL
Can anyone give me a hand on how to pull that out? If a subquery is needed, each record does have an id field as a primary key as well.




Reply With Quote