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

highest salary from each dept in a table


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
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
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
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
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

Superior Member


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

PostPosted: Thu Dec 31, 2009 3:36 pm
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

Moderator Emeritus


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

PostPosted: Fri Jan 01, 2010 2:04 am
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: 8797
Location: Welsh Wales

PostPosted: Fri Jan 01, 2010 2:22 pm
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
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

Moderator Emeritus


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

PostPosted: Thu Jan 07, 2010 8:45 pm
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: 1249
Location: Richfield, MN, USA

PostPosted: Fri Jan 08, 2010 6:42 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top