Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

SQL query for join table and multiple values

$
0
0
Trying to join two tables , Emphours and EmpStatus to get
result which gives each emplyees hour worked each day
in past  say 1 year in what status. I need result similar to table 3 , Hours Can also be grouped per week
all I need Is Each employees hours in each week and his status and position at that time if possible
any help will be highly appreciated. Thank you 
note: payday is every other Friday- week runs from Saturday through Friday
EmpStatus Table tracks when employees status changed
EmpHours
employeeworkdaypaydayhoursposition
1011/1/20141/3/20148assistant
1011/3/20141/3/20148assistant
1011/4/20141/17/20148assistant
1011/5/20141/17/20148assistant
1011/7/20141/17/20148assistant
1011/8/20141/17/20148assistant
1011/9/20141/17/20148assistant
1011/11/20141/17/20148assistant
1011/13/20141/17/20148assistant
1011/14/20141/17/20148assistant
1011/18/20142/14/20148assistant
1021/1/20141/3/20147manager
1021/25/20141/31/20147manager
1021/26/20141/31/20147manager
1021/28/20141/31/20147manager
1021/31/20141/31/20147manager
1031/1/20141/3/20145intern
1031/31/20141/31/20146intern
1041/14/20141/17/20145supervisor
1041/30/20141/31/20146supervisor
EmpStatus
employeestart_datestatus
1011/1/2014parttime
1011/18/2014fulltime
1021/1/2014seasonal
1021/18/2014fulltime
1031/1/2014partime
1031/18/2014fulltime
1041/4/2014parttime
1041/18/2014fulltime
Table 3
employeestatushourspositionworkdayweekendpayday
101parttime8assistant1/1/20141/3/20141/3/2014
101parttime8assistant1/3/20141/3/20141/3/2014
101parttime8assistant1/4/20141/10/20141/17/2014
101parttime8assistant1/5/20141/10/20141/17/2014
101parttime8assistant1/7/20141/10/20141/17/2014
101parttime8assistant1/8/20141/10/20141/17/2014
101parttime8assistant1/9/20141/10/20141/17/2014
101parttime8assistant1/11/20141/17/20141/17/2014
101parttime8assistant1/13/20141/17/20141/17/2014
101parttime8assistant1/14/20141/17/20141/17/2014
101fulltime8assistant1/18/20141/24/20142/14/2014
102seasonal7manager1/1/20141/3/20141/3/2014
102fulltime7manager1/25/20141/25/20142/14/2014
102fulltime7manager1/26/20141/26/20142/14/2014
102fulltime7manager1/28/20141/28/20142/14/2014
102fulltime7manager1/31/20141/31/20142/14/2014
103parttime5intern1/1/20141/3/20141/3/2014
103fulltime6intern1/31/20141/31/20142/14/2014
104parttime5supervisor1/14/20141/17/20141/17/2014
104fulltime6supervisor1/30/20141/31/20141/31/2014












































































































































































































































































Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>