Re: sql query problem
From: Thomas J Kyte <tkyte_at_us.oracle.com>
Date: 1996/01/20
Message-ID: <4drcpq$236_at_inet-nntp-gw-1.us.oracle.com>#1/1
Date: 1996/01/20
Message-ID: <4drcpq$236_at_inet-nntp-gw-1.us.oracle.com>#1/1
Heather Dyson <heather.dyson_at_template.com> wrote:
>I have a table that has a primary key of
>number, code, month
>Let's say that I have the following data
>number code month
>------ ---- -----
>1 a 1
>1 b 1
>1 b 2
>I want to formulat a query so that I get only the rows with the greatest
>month values for number and code. So the result of my query for the
>example would be
>number code month
>------ ---- -----
>1 a 1
>1 b 2
select *
from T a
where a.month = ( select max(MONTH)
from T b where b.num = b.num and b.code = a.code )
>I know this is probably easy, but I would appreciate any help.
>Thanks,
>Heather
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Received on Sat Jan 20 1996 - 00:00:00 CET