Home » SQL & PL/SQL » SQL & PL/SQL » Max sal
Max sal [message #232911] Tue, 24 April 2007 00:32 Go to next message
akkumar81
Messages: 144
Registered: February 2007
Location: india
Senior Member



Hi ,

I have a table Emp.In this table I want a records in 3 and 4th max salary in emp table in same query . I give an input 3 and 4 .

output:

3000 ford
4000 maxwell


first records is 4 max and second record is 3 max.I want single query in this output. Anybody help Me.


Arunkumar
Re: Max sal [message #232915 is a reply to message #232911] Tue, 24 April 2007 01:02 Go to previous message
ammishra
Messages: 179
Registered: January 2007
Location: india
Senior Member
SELECT d.empno
     , d.sal
FROM   (SELECT DENSE_RANK () OVER (ORDER BY sal DESC) RANK
             , empno
             , sal
        FROM   emp) d
WHERE  d.RANK IN (:a, :b)


--Yash

[Updated on: Tue, 24 April 2007 01:28] by Moderator

Report message to a moderator

Previous Topic: help on sql query
Next Topic: multiple update statements
Goto Forum:
  


Current Time: Mon Dec 05 04:43:55 CST 2016

Total time taken to generate the page: 0.15080 seconds