Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 A couple of Interview Questions on Co... viplavmodi36 Mainframe Interview Questions 5 Fri Feb 23, 2018 6:21 pm
No new posts JES2 EXIT 6 QUESTION Randy Horowitz All Other Mainframe Topics 30 Tue Feb 06, 2018 5:47 pm
No new posts question about dfsms management clas... Hervey Martinez IBM Tools 0 Tue Oct 10, 2017 6:19 pm
No new posts Question related to Data dictionary f... rexx77 SYNCSORT 3 Thu Aug 31, 2017 7:23 am
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us