Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

highest salary from each dept in a table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
l.nethaji

New User


Joined: 16 Mar 2008
Posts: 90
Location: tamil nadu

PostPosted: Thu Dec 31, 2009 9:50 am    Post subject: highest salary from each dept in a table
Reply with quote

Hi,

I have a table T .I have 5 Dept sat D1 to D5 .I have find the max sal in each dept .Could you please let me know the DB2 query for the same
Back to top
View user's profile Send private message

l.nethaji

New User


Joined: 16 Mar 2008
Posts: 90
Location: tamil nadu

PostPosted: Thu Dec 31, 2009 9:51 am    Post subject: Hi
Reply with quote

Select max (sal) from T1
Where t1.dept = ( select dept from T1 a where T1.sal = a.sal)


Whether the above query is right
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu Dec 31, 2009 10:22 am    Post subject:
Reply with quote

Below query will give you desired result.
Code:

SELECT dept,MAX(sal)       
FROM T1 GROUP BY dept;                       
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu Dec 31, 2009 3:36 pm    Post subject:
Reply with quote

Is it an Interview question? I'd like to move it there...
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri Jan 01, 2010 2:04 am    Post subject: Reply to: highest salary from each dept in a table
Reply with quote

Hi Anuj,

I'd flip a coin to choose between an interview question and homework icon_wink.gif

Happy New Year!

d
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Jan 01, 2010 2:22 pm    Post subject: Re: Hi
Reply with quote

l.nethaji wrote:
Whether the above query is right

What is this, a mainframe guessing forum. If you have NOT tested something then either state quite categorically that it is not tested and the logic used behind your post, or better still DO NOT POST AT ALL
Back to top
View user's profile Send private message
l.nethaji

New User


Joined: 16 Mar 2008
Posts: 90
Location: tamil nadu

PostPosted: Wed Jan 06, 2010 9:15 pm    Post subject: highest salary from each dept in a table
Reply with quote

Hi,

As i am working in a IDMS database i amnot able to practice it in Db2 environment.

I just want to make sure the logic is right in the above query

That the reason behind why i mentioned it as a questionary.


Thanks,
L.Nethaji
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Jan 07, 2010 8:45 pm    Post subject:
Reply with quote

Hello,

Quote:
As i am working in a IDMS database i amnot able to practice it in Db2 environment.
Would have been a good idea to mention this in the original post. . . .
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1239
Location: Richfield, MN, USA

PostPosted: Fri Jan 08, 2010 6:42 am    Post subject:
Reply with quote

Quote:
Would have been a good idea to mention this in the original post. . . .

Not if it happens to be psychic day. icon_lol.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 -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm
No new posts Command UNIQUE CONSTRAINT on any tabl... rohanthengal DB2 2 Thu Aug 18, 2016 3:48 pm
No new posts Updating online Db2 table kishpra DB2 3 Fri Aug 12, 2016 2:44 pm
No new posts Getting soc4 on internal table in cobol abdulrafi COBOL Programming 13 Fri May 06, 2016 3:39 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us