Home » SQL & PL/SQL » SQL & PL/SQL » SQL problem
SQL problem [message #18716] Tue, 12 February 2002 03:12 Go to next message
Messages: 29
Registered: September 2000
Junior Member
I have a table taxes with three columns
l_code varchar2(5)
e_code varchar2(5) and
duty number(9,2)

Say these are sample records in the table
l_code e_code duty
AA001 XX001 1000
AA001 XX002 2000
AA002 YY001 500
AA002 YY002 3000
AA003 ZZ001 4000
AA003 ZZ002 1500
I want the output to be:
AA001 XX002 2000
AA002 YY002 3000
AA003 ZZ001 4000
The maximum duty and its e_code under every l_code.
We had done it using a view. But how to do it in SQL query itself.

Re: SQL problem [message #18718 is a reply to message #18716] Tue, 12 February 2002 03:55 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
select * from
taxes t1 where duty=(select max(duty) from taxes t2 where t2.l_code=t1.l_code)
Previous Topic: explain plan
Next Topic: 'ignore = y ' still IMP-00019: row rejected due to ORACLE error 1
Goto Forum:

Current Time: Fri Sep 24 13:58:58 CDT 2021