Combining multiple records on one row in Crystal
Folks, I'm fairly novice at Crystal, but have been using SQL for some time...I've searched the forums but none of the threads I've seen on this topic really have worked.
SELECT EmployeeId,
Case when Datepart(dw,WorkDate) = 1 Then WorkName Else 'X' End as "Sunday",
Case When Datepart(dw,WorkDate) = 2 Then WorkName Else 'X' End as "Monday",
Case when Datepart(dw,WorkDate) = 3 Then WorkName Else 'X' End as "Tuesday",
Case when Datepart(dw,WorkDate) = 4 Then WorkName Else 'X' End as "Wednesday",
Case when Datepart(dw,WorkDate) = 5 Then WorkName Else 'X' End as "Thursday",
Case When Datepart(dw,WorkDate) = 6 Then WorkName Else 'X' End as "Friday",
Case When Datepart(dw,WOrkDate) = 7 Then WorkName Else 'X' End as "Saturday"
FROM Work
WHERE WorkDate Between 20081201 AND 20081205
CURRENT OUTPUT
EmployeeId Monday Tuesday Wednesday Thursday Friday Saturday
1..................X..........X.............X..... .......1C..........X.......X
1..................X..........X.............X..... .......X..........17A.....X
2..................17A.......X.............X...... ......X............X......X
2..................X..........1C............X..... .......X............X......X
2..................X..........X.............3D.... .......X............X......X
2..................X..........X.............17A... .......X............X......X
DESIRED OUTPUT
EmployeeId Monday Tuesday Wednesday Thursday Friday Saturday
1..................X..........X.............X..... .......1C.........17A.......X
2..................17A.......1C...........3D...... ....X............X.........X
(continued row for 2).................17A............................ ......
(the 2 in parenthesis illustrates that I need to be able to show any value other than null for the employeeid on the given day)
I'm not real savvy with Crystal so I often put my SQL statements into the Command Table
from Database Expert which tends to be easier for me.
Does anyone have any suggestions for how to accomplish the desired output in Crystal XI?
Thanks!
Flam, December 5th, 2008 05:21 PM
Bookmarks