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
 

 

DB2 interview question

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: DB2 interview question
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: 1278
Location: Belgium

PostPosted: Mon May 17, 2010 6:18 pm    Post subject:
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    Post subject: Reply to: DB2 interview question
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    Post subject:
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    Post subject: Reply to: DB2 interview question
Reply with quote

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

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Mon Jul 19, 2010 1:54 pm    Post subject:
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    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 Fault Analyzer - listings question. egrove IBM Tools 4 Thu Aug 11, 2016 5:31 pm
No new posts dataset copy question - REPRO or some... atulxp TSO/ISPF 2 Wed Aug 03, 2016 10:56 pm
No new posts SQL Order By related question Joseph K Thomas DB2 8 Fri Mar 18, 2016 12:53 pm
No new posts DFSort Question krrp DFSORT/ICETOOL 9 Mon Mar 07, 2016 7:11 pm
No new posts Where can i find Interview questions ... Elixir Mainframe Interview Questions 4 Sat Feb 20, 2016 12:38 am


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