1. Registered User
Join Date
Feb 2012
Posts
5

Hi,

I need urgent answer to this query. I need a sql query to get 3-11 table from 3-10

Calculate the employee attrition Table 3-11 from the Employee master, Table 3-10

Table 3-10: Employee Master

Employee ID Start Date Termination Date Performance Level
1 1/1/2007 3/1/2007 Low
2 6/5/2004 Medium
3 4/3/2003 High
4 9/1/2002 4/15/2007 Medium
5 4/6/2007 11/1/2007 Low
6 7/1/2007 High
7 3/2/2005 8/1/2007 Low

Table 3-11: Employee Attrition

Period Total Employees at end of quarter High Performers Medium Performers Low Performers Total Attrition Low Performer Attrition Medium Performer Attrition High Performer Attrition
Q1 2007 4 1 2 1 1 1 0 0
Q2 2007 4 1 1 2 1 0 1 0
Q3 2007 4 2 1 1 1 1 0 0
Q4 2007 3 2 1 0 1 1 0 0
Last edited by sqlprogrammer1; 02-17-12 at 01:25. Reason: More details

2. Registered User
Join Date
Feb 2008
Location
Japan
Posts
3,483
The question looks same as in MySQL forum.
Originally Posted by sqlprogrammer1
Hi,

I need urgent answer to this query. Need to write a sql query to get table 3-11 from 3-10

Calculate the employee attrition Table 3-11 from the Employee master, Table 3-10

...

3. Registered User
Join Date
Feb 2012
Posts
5

## yes

I need answer urgently so I posted in both the forums. Sorry about that.

4. SQL Consultant
Join Date
Apr 2002
Location
Posts
20,002
desperate sql student is desperate
homework is due and she hasn't a clue

5. Registered User
Join Date
Nov 2004
Posts
1,428
You will find a lot of people here willing to help you out, but very few willing to do your homework for you.

Show us what you have got till now and we'll help you further.

Start by building your result set step by step.
How would you create the Period result?

4 9/1/2002 4/15/2007 Medium
This period starts in Q3 2002 ..... and ends in Q2 2007. What is the business logic to convert it into Period in the result?
Q3 2002, Q2 2007, both Q3 2002 and Q2 2007, all Q3 2002 | Q4 2002 | Q1 2003 | ... | Q1 2007 | Q2 2007, .... ?

When you got that, continue with "Employees at end of quarter" and so on.

6. Registered User
Join Date
Jan 2013
Posts
1
Hi, HAve you found and answer yet? Even Im looking for the answer!!!

7. Registered User
Join Date
Jan 2013
Posts
359
Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.

This is minimal polite behavior on SQL forums.

Sample data is also a good idea, along with clear specifications. It is very hard to debug code when you do not let us see it.

8. Registered User
Join Date
Aug 2004
Location
Dallas, Texas
Posts
831
Yikes! Joe this is a yearly post. OP probably failed class and became successful programmer for a fortune 50 company.

9. World Class Flame Warrior
Join Date
Jun 2003
Location
Ohio
Posts
12,595