Friday 15 February 2013

ssms - Retrieving data from specific columns of multiple rows in sql -


I have a table that stores the information as follows and has the ID as the primary key:

Link Table View:

ID Timeline JobAir 1 hour 1 employee 2 hours 2 employees 3 hours 3 employees 4 hours 4 employees 5 hours 5 employees 6 hours 6 employees 7 hours 7 employees 8 hours 8 1 7/1/2014 W1A 8B 7C4D3 Faucet 0 NULL 0 NULL 0 NULL 0 2 7/1/2014 W2 B 8 C 8 0 0 0 NULL 3 7/1/2014 W3C8 A8E8F8 zero Nail nail nail nail nail nail nail 4 7/1 / 2014 w 4 d 8 b8f8 nail nail nail nail faucet null 5 7/1/2014 w5 e 8 c 8 nail nail nail nail nail nail nail nail nail tap null Null 6 7/1/2014 W 6 F8 D8 8 Nail Nail Nail NULL NULL NULL NULL Zero Null 7 8/1/2014 W1 G4 Zero Nail Nail Nail Nail Nail Nail Nail Nail Nail Nail 8 8/1/2014 W 2 A4 Nell nail nail nail nail nail nail nail nail nail nail null 9 8/1/2014 W3B For any special schedule date , only one can be WorkArea < / Code> (8) 8F8 8 8 Nell nail nail nail nail nail nail nail null

ScheduleDate and WorkArea combinations are unique). Now, I want to know if there is no more than 8 hours of any particular employee at any one date. For example, an employee's special date (hours 1, hour 2 or table may be based on the placement of the employee) should not be more than 8 hours.

Thank you

Ally nicknames are not required on the E.D. queries:

 with  T (select the scheduledet, workararias, employee 1 as an employee, hour 1 as human union) Schedule dates, workers, employee 2 as employee, hours 2 hours as union ... ScheduleDate, employee 8 as employee, hours as 8 hours Select) t group ScheduleDate as ScheduleDate, employee, amount (hours), HRS) & gt; 8  

No comments:

Post a Comment