|
Posted by Plamen Ratchev on 09/30/36 12:00
I think your query returns the same results only by coincidence. If you have
only the following rows in table SAF2_Status:
Course | Status | Action Date
--------- ---------------- ----------------
1111 DEPTQUEUE Jan-1-2008
1111 DEPTRMVLST Jan-5-2008
Then your query will return course 1111 because 'Jan-1-2008' is the latest
date according to your subquery conditions and it satisfies the WHERE
conditions. And this is incorrect according to your requirements.
Your query may return the correct results if you have another row like below
(and you probably have such rows, which is the reason you see the results
matching):
Course | Status | Action Date
--------- ---------------- ----------------
1111 DEPTABCDE Jan-3-2008
Note, it is another code not in the list ('DEPTSETUP', 'DEPTQUEUE',
'CERTRN', 'DEPTCORRREQ') which now has the latest Action Date because code
'DEPTRMVLST' is excluded.
HTH,
Plamen Ratchev
http://www.SQLStudio.com
Navigation:
[Reply to this message]
|