Need SQL idea
HI All,
I have data in below format.
Staff | Date | Hours Worked |
12345 | 07-sep-15 | 6 |
12345 | 08-sep-15 | 6 |
12346 | 07-sep-15 | 8 |
12346 | 08-sep-15 | 8 |
12347 | 07-sep-15 | 10 |
12347 | 08-sep-15 | 10 |
12348 | 07-sep-15 | 8 |
12348 | 08-sep-15 | 8 |
I would like to have the data represented as:
Staff | Week Beginning (07 Sep2015) | Week Beginning (14 Sep2015) | Week Beginning (21 Sep2015) | Week Beginning (28 Sep2015) |
12345 | ||||
12346 |
1.I need to calculate the sum of hours worked for one week from (mon to sun) for all the employees
2.i need to be able dynamically change the week columns to for the next month for eg: OCTOBER should be 05-OCT-2015,12-OCT-2015,19-OCT-2015,26-OCT-2015 and generate a report for one month
Thanks for any valuable inputs!