Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Second max value

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

New User


Joined: 25 May 2005
Posts: 53
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

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

New User


Joined: 25 May 2005
Posts: 53
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:


Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us