Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL QUESTION
Mark wrote:
>
> ggstr wrote:
> > i have a table with 3 fields : OBJECT,DATE,VALUE
> > every object can have many values with different date
> >
> > i want to display only the last value for each object(date most recently)
> > like this: object,date,value
> >
> > what is the good sql code to to this?
>
> SELECT MAX(date)
> ,object
> ,value
> FROM mytable
> GROUP BY object
> ,value
> /
I read the question more as:
SELECT * FROM mytable WHERE (object, date) IN (SELECT object, MAX(date) FROM mytable GROUP BY object)
i.e., finding the most recent record for each object and returning the value.
MF
-- matt_foster_uk_at_yahoo.co.ukReceived on Tue Sep 19 2000 - 06:56:35 CDT
![]() |
![]() |