Re: sql query problem
Date: 1996/01/19
Message-ID: <4dp0df$t74_at_lserv1.paging.mot.com>#1/1
Heather,
This is one possible solution:
select c1,c2,c3
from vgt a
where c1||c3 in
(select max(b.c1||b.c3) from vgt b where b.c2 = a.c2)
/
Table vgt values are:
select * from vgt
2 /
C C C
- - -
1 a 1
1 b 1
1 b 2
SQL> desc vgt
Name Null? Type ------------------------------- -------- ---- C1 VARCHAR2(1) C2 VARCHAR2(1) C3 VARCHAR2(1)
Hope this helps,
Vikram Goel
Sr. DBA ( Consultant)
Aerotek Inc, Florida
e-mail: vgoel_at_emi.net
In article <4dog2a$cqh_at_template.com>, Heather Dyson <heather.dyson_at_template.com> writes:
>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
>
>I know this is probably easy, but I would appreciate any help.
>Thanks,
>Heather
>
Received on Fri Jan 19 1996 - 00:00:00 CET