Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
seethem
Starting Member
46 Posts |
Posted - 2011-02-13 : 12:43:46
|
| Folks,I need to transpose data from 1 form to another...My _SOURCE_TBL looks like this:-------------------------------------------------------| EmployeeNumber | Date | StartTime | MinsWorkedMorning| MinsWorkedAfternoon | MinsWorkedNight |-------------------------------------------------------Example of a row in that table _SOURCE_TBL:-------------------------------------------------------| 21 | 2011/02/02 | 15:00 | 0 | 120 | 45 |-------------------------------------------------------Now I need to convert that into a table (for business analysis) that looks like this:------------------------------------------------------| EmployeeNumber | Date | HoursWorked | MinsWorked------------------------------------------------------| 21 | 2011/02/02 | 15:00 | 60| 21 | 2011/02/02 | 16:00 | 60| 21 | 2011/02/02 | 17:00 | 45------------------------------------------------------As you can see the other hours in the day may be useful, but they'll be omitted when presented as a cube.We can assume that the employee works a continuous period of time.-----------Seethem!!! |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-02-13 : 19:29:36
|
The Morning, Afternoon & Night is from what time to what time ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
seethem
Starting Member
46 Posts |
Posted - 2011-02-13 : 23:20:32
|
| Lets say morning is 8-11:59, afternoon is 12-15:59 and night is 16-20 |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-02-14 : 21:27:19
|
quote: Originally posted by seethem Lets say morning is 8-11:59, afternoon is 12-15:59 and night is 16-20
if night is from 16-20how do you get this| 21 | 2011/02/02 | 17:00 | 45 KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
seethem
Starting Member
46 Posts |
Posted - 2011-02-18 : 08:52:20
|
| KT,I was able to get what I want using the UNPIVOT command.Thanks for the assistance!Phill |
 |
|
|
|
|
|