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: 1281
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: 1281
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 QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts The Last Two Question For You To Ask ... CaptBill Mainframe Interview Questions 0 Fri Apr 14, 2017 5:42 am
No new posts Asynchronous CICS Processing Question moezbud CICS 1 Mon Mar 06, 2017 6:13 pm
No new posts CICS Question RE: Browse, Readnext an... moezbud CICS 7 Sun Mar 05, 2017 5:45 am
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm


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