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

Write a query to list those employees who have served


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

New User


Joined: 07 May 2005
Posts: 22

PostPosted: Fri Oct 05, 2007 11:39 am
Reply with quote

Hi Friends,

An EMP_PROJ table has following fields:
EMP_ID, EMP_NAME, PROJ_ID, PROJ_NM, EFF_DT, EXP_DT
Key of the table is EMP_ID + PROJ_ID + EFF_DT.

a. Write a query to list those employees who have served in at least 3 projects, and they are not on bench currently. Bench PROJ_ID = 99999.

b. Write a query to list those employees who have served in at least 3 projects, and they are on bench currently. Bench PROJ_ID = 99999.

c. Write a query to list those employees who were on bench before they left the company.

d. Write a query to list those employees who have served at least 1 month in their last project.

e. Write a query to list employees and their project experience till date.
Back to top
View user's profile Send private message
Help-Me-Out

New User


Joined: 09 Dec 2006
Posts: 56
Location: Pune

PostPosted: Fri Oct 05, 2007 5:02 pm
Reply with quote

Hi,

I thing only one query will do for your answer, only thing is you need to replace the condition accordingly.

Here is your answer:

a.
SELECT COUNT(PROJ_ID) AS A , EMP_ID, EMP_NAME
FROM EMP_PROJ
GROUP BY PROJ_ID
HAVING COUNT(PROJ_ID) > 2 AND PROJ_ID != '99999'
Back to top
View user's profile Send private message
nuthan

Active User


Joined: 26 Sep 2005
Posts: 146
Location: Bangalore

PostPosted: Fri Oct 05, 2007 5:58 pm
Reply with quote

1)
SELECT EMP_ID, EMP_NAME FROM EMP_PROJ WHERE PROJ_ID <> 99999 AND EMP_ID IN (SELECT EMP_ID FROM EMP_PROJ GROUP BY (EMP_ID) HAVING COUNT(*) > 3 );

2)
SELECT EMP_ID, EMP_NAME FROM EMP_PROJ WHERE PROJ_ID = 99999 AND EMP_ID IN (SELECT EMP_ID FROM EMP_PROJ GROUP BY (EMP_ID) HAVING COUNT(*) > 3 );
Back to top
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Fri Oct 05, 2007 7:35 pm
Reply with quote

Hi All,

Nuthun answered excellently, keep a top Nuthan.

Quote:
c. Write a query to list those employees who were on bench before they left the company.


Elaborate your question I mean for status of employee (in which table status column is available and status column)

But u can use below query if know status and status table.

SELECT EMP_ID, EMP_NAME FROM EMP_PROJ WHERE PROJ_ID = 99999 AND STATUS_EMP = 'NOT ACTIVE' (GIVE STATUS CONDITION HERE);

Quote:
d. Write a query to list those employees who have served at least 1 month in their last project.


SELECT EMP_ID, EMP_NAME FROM EMP_PROJ
WHERE EFF_DT(MONTH(EXP_DT - EFF_DT ) >= 1 AND
EFF_DT IN (SELECT MAX(EFF_DT) FROM EMP_PROJ);

Use above query, If error found let us know, So that again we can look into it..

Quote:
e. Write a query to list employees and their project experience till date.


SELECT EMP_ID, EMP_NAME, (MONTH(EXP_DT - EFF_DT ) AS EXPERIENCE
FROM EMP_PROJ
GROUP BY EMP_ID, EMP_NAME
HAVING COUNT(EMP_ID) >= 1;

Use above query, If error found let us know, So that again we can look into it..

Regards
Back to top
View user's profile Send private message
murali_andaluri
Currently Banned

New User


Joined: 07 May 2005
Posts: 22

PostPosted: Mon Oct 08, 2007 2:40 pm
Reply with quote

Hi Friends,

Thank you very much for your quick answers.
Back to top
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Tue Oct 09, 2007 12:58 pm
Reply with quote

Hi Murali,

Quote:
Hi Friends,

Thank you very much for your quick answers.



Let us know whether you had got answer or not?

Thanks N Regards
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 Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts RC query -Time column CA Products 3
No new posts How to create a list of SAR jobs with... CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top