IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SQL query to find the 2nd highest salary using Fetch First.


IBM Mainframe Forums -> DB2
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
arindambanerjee

New User


Joined: 30 Jun 2007
Posts: 39
Location: India

PostPosted: Wed Dec 09, 2009 9:55 pm
Reply with quote

Hi All,

Can you please suggest if the below SQL query will extract the details of the employee with 2nd highest salary from EMP table:

Select * from EMP where sal=(
(select sal from EMP having sal=max(sal) fetch first 2 rows only ordered by descending)
) fetch first 1 row only ordered by ascending;;;
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Dec 09, 2009 10:17 pm
Reply with quote

suggest you run it in spufi or qmf.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Dec 09, 2009 10:29 pm
Reply with quote

Hello,

And you saw some reason to re-post this? Your original was moved to Homework from this part of the forum as it is a standard" homework assignment.

Post a question only once. . .

This dulicate is locked. . .

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Query on edit primary command CLIST & REXX 5
Search our Forums:

Back to Top