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
 

 

Write a query to list those employees who have served

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: Write a query to list those employees who have served
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    Post subject: Reply to: Write a query to list those employees who have ser
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    Post subject: Reply to: Write a query to list those employees who have ser
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: Chennai

PostPosted: Fri Oct 05, 2007 7:35 pm    Post subject:
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    Post subject: Reply to: Write a query to list those employees who have ser
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: Chennai

PostPosted: Tue Oct 09, 2007 12:58 pm    Post subject:
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    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 Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts member list compare jzhardy TSO/ISPF 6 Fri May 12, 2017 3:18 pm


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