| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL: find all latest value = 'X'
On Sun, 12 Oct 1997 23:00:55 -0400, Jeff Bangle <JBangle_at_erols.com> wrote:
>personid rating ratingdate
>======== ====== ==========
>01000101 B 10-JAN-97
>12304956 22-NOV-96
>10203049 A 15-DEC-96
>01000101 A 10-JUL-96
>
>I need to find all personid's where the most recent rating for that
>person was 'A'. Null ratings don't count. I've come up with a query
>that seems to work, but it looks messy:
How about this:
SELECT A.PERSONID , A.RATINGDATE FROM RATING_TABLE A WHERE A.RATINGDATE = (SELECT MAX(RATINGDATE) FROM RATING_TABLE B WHERE B.RATING = 'A' AND A.PERSONID = B.PERSONID) ------------------------------------------------------------------------------- --- Martin Jesterhoudt--- martinj(replace this by @)xs4all.nl
![]() |
![]() |