Home » SQL & PL/SQL » SQL & PL/SQL » second Highest cost from each dept
second Highest cost from each dept [message #23395] Thu, 05 December 2002 02:22 Go to next message
sri
Messages: 154
Registered: February 2000
Senior Member
Can Anybody tell urgent
There is a table - related to a Inventory - which contains the following
cols.

1. Item Name
2. Item Cost
3. Date Arrived
4. Department.

Department - is the dept to which this item belongs to OR the dept which
uses this item.

Now,

I want a query for 'Listing the items of second highest cost in each dept and
arrived in the month of October (irrespective of year)'.
Re: second Highest cost from each dept [message #23396 is a reply to message #23395] Thu, 05 December 2002 04:25 Go to previous messageGo to next message
Kavitha
Messages: 40
Registered: December 1999
Member
Hi,

If you are using a database higher than 8.0 then you can use the analyze function. Can you tell me your database version?

Cheers
Kavitha
Re: second Highest cost from each dept [message #23398 is a reply to message #23396] Thu, 05 December 2002 05:35 Go to previous message
Ramki
Messages: 26
Registered: September 2002
Junior Member
try this

Select dep,max(sal)
From DBO.temp a
where sal < (Select max(sal)
From DBO.temp b
where a.DEP = b.dep )
group by dep
Previous Topic: Create a Database link
Next Topic: Please Any help in writing this query
Goto Forum:
  


Current Time: Wed May 15 12:52:38 CDT 2024