Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL help
Try:
select id,date from visits v1 where rank in ( select max(rank) from visits v2 where v1.id=v2.id);
The subselect should return the highest rank value for a given ID. This query should then return that ID and also the date on which the highest rank occurred. Note that if you have a tie, i.e. two dates with the same rank, that both will be returned.
regards,
Jonathan Gennick
On Tue, 28 Oct 1997 12:34:24 -0500, "H. John C. Hopkins" <john_spam_free_at_hpe.ufl.edu> wrote:
>Table VISITS
>Fields ID, DATE, RANK
>
>ID is not a primary key (i.e., can have multiple occurrences of ID, each
>with different dates and ranks)
>
>Need to select id AND date where highest rank value.
>
>Thanks so much for your input.
>
>-John
>
>
>
>
![]() |
![]() |