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: 6965
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: 19243
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. All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts DB2 Query to get the count of Unique ... DB2 2
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 1
No new posts sort to find out the char which repea... Mainframe Interview Questions 10
No new posts Compare 2 alphabets in a REXX and fin... CLIST & REXX 2
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 5
Search our Forums:


Back to Top