LloydDobler
Technical User
Is there any way I can turn the following code into the desired results? I currently only get 'A shift' showing up
DESIRED RESULTS:
shift MON TUES WED THU FRI
A 1.2 3.2 0 0 0
B 0 0 0 0 0
C 0 0 0 0 0
"I don't want to sell anything, buy anything or process anything as a career. I don't want to sell anything bought or processed... or buy anything sold or processed... or process anything sold, bought or processed... or repair anything sold, bought or processed. You know, as a career, I don't want to do that."
DESIRED RESULTS:
shift MON TUES WED THU FRI
A 1.2 3.2 0 0 0
B 0 0 0 0 0
C 0 0 0 0 0
Code:
SELECT shift,
SUM(CASE DATENAME(dw, dbo.tbl_production.PRDdate) WHEN 'MONDAY' THEN dbo.tbl_production.TotalTime ELSE 0 END) AS MON, etc through all days of the week
FROM dbo.tbl_production LEFT OUTER JOIN
dbo.tbl_machinenumbers
ON dbo.tbl_machinenumbers.machinenumber = dbo.tbl_production.MachineNumber
WHERE (DATEPART(yy, dbo.tbl_production.PRDdate) = DATEPART(yy, GETDATE())) AND (dbo.tbl_production.Division = 1) AND (dbo.tbl_production.workcentre LIKE 'C%') AND (DATEPART(ww, dbo.tbl_production.PRDdate) = DATEPART(ww, GETDATE())) AND dbo.tbl_machinenumbers.machgroup = 'ZONE 1'
GROUP BY shift
"I don't want to sell anything, buy anything or process anything as a career. I don't want to sell anything bought or processed... or buy anything sold or processed... or process anything sold, bought or processed... or repair anything sold, bought or processed. You know, as a career, I don't want to do that."