Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Q: select query - I want one row to be unique

Re: Q: select query - I want one row to be unique

From: David Fitzjarrell <oratune_at_msn.com>
Date: 7 Aug 2001 07:25:14 -0700
Message-ID: <32d39fb1.0108070625.61c1dcdb@posting.google.com>

Jacob,

Try this:

select p.product, price, p.mydate
from T p,
(select product, max(mydate) mydate from T group by product) d where p.product = d.product
and p.mydate = d.mydate;

The output should look like this:

   PRODUCT PRICE MYDATE

---------- ---------- ---------
         1         13 07-AUG-01
         2         14 03-AUG-01

David Fitzjarrell

jacob_nordgren_at_hotmail.com (Jacob Nordgren) wrote in message news:<47c6b9be.0108070125.21f353e0_at_posting.google.com>...
> Hi,
>
> I have this data
>
> PRODUCT PRICE MYDATE
> 1 12 2001-08-01
> 1 13 2001-08-07
> 2 14 2001-08-03
>
> I want to get a list of all the products with the latest price only
> (no duplicate products). I know how to do the query without the price
> part:
>
> "SELECT PRODUCT, MAX(MYDATE) FROM T GROUP BY PRODUCT" works fine.
>
> How can I include the PRICE column into the result?
>
> / Jacob
Received on Tue Aug 07 2001 - 09:25:14 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US