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

DB2 interview question


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
maintenure

New User


Joined: 22 Sep 2008
Posts: 10
Location: bangalore

PostPosted: Mon May 17, 2010 4:14 pm
Reply with quote

Hi

Two tables are there as follows:

Employee table:

Employee ID | Employee name| Dept ID

Dept table:

Dept ID | Dept name

In employee table emplid is the key,dept table dept id is the key and dept id is the foriegn key.

I want the dept name with employees more than 100.

It is an interview question in IBM.I could nt able to answer.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Mon May 17, 2010 6:18 pm
Reply with quote

Code:
select d.name
from sysibm.sysdatabase D
    , (select dbid from sysibm.systablespace
       group by dbid
       having count(*) > 100) A
where a.dbid = d.dbid
Back to top
View user's profile Send private message
maintenure

New User


Joined: 22 Sep 2008
Posts: 10
Location: bangalore

PostPosted: Mon May 17, 2010 7:37 pm
Reply with quote

Thanks .
Back to top
View user's profile Send private message
lvani

New User


Joined: 26 May 2010
Posts: 3
Location: Chennai

PostPosted: Mon Jul 12, 2010 5:08 pm
Reply with quote

This is the correct query

select d.deptname from employee e , dept d
where e.deptid = d.deptid
group by dept_id
Having count(*) > 100
Back to top
View user's profile Send private message
maintenure

New User


Joined: 22 Sep 2008
Posts: 10
Location: bangalore

PostPosted: Mon Jul 12, 2010 5:26 pm
Reply with quote

Thanks !
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Mon Jul 19, 2010 1:54 pm
Reply with quote

lvani wrote:
This is the correct query

select d.deptname from employee e , dept d
where e.deptid = d.deptid
group by dept_id
Having count(*) > 100

funny, because this fails
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 Question for file manager IBM Tools 7
No new posts question for Pedro TSO/ISPF 2
No new posts question on Outrec and sort #Digvijay DFSORT/ICETOOL 20
No new posts panel creation question TSO/ISPF 12
No new posts Sort w/OUTREC Question DFSORT/ICETOOL 2
Search our Forums:

Back to Top