Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Second max value

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
Author Message
ideas

Active User


Joined: 25 May 2005
Posts: 54
Location: India

PostPosted: Wed Aug 03, 2005 11:28 am    Post subject: Second max value
Reply with quote

Hi All,

my query is how to Obtain Second maximum value from any table..

thnx.
Back to top
View user's profile Send private message
References
paru

New User


Joined: 24 Jun 2005
Posts: 9
Location: INDIA

PostPosted: Wed Aug 03, 2005 2:02 pm    Post subject: Re: Second max value
Reply with quote

I can give you the logic if not the exact query to get this result.The answer you are searching is a subquery.Suppose you have to find the second maximum salary from EMPL table.
Try this :
SELECT MAX(SALARY) FROM EMPL WHERE
SALARY <(SELECT MAX(SALARY) FROM EMPL)

hope this helped! icon_smile.gif

Regards,
Paru.
Back to top
View user's profile Send private message
ideas

Active User


Joined: 25 May 2005
Posts: 54
Location: India

PostPosted: Wed Aug 03, 2005 2:56 pm    Post subject:
Reply with quote

hey paru!! thanks. I tried and it worked fine.

icon_razz.gif
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1