INSERT INTO staging2 ([Date worked], ItemId, ItemTypeId, [Hours Worked], [Employee Name], [Type of Work], PConcatex, CConcatex, Parent, Rate)
SELECT [Date worked]
,[Type of Work]
,CASE WHEN ItemTypeId IN (1) THEN ST.ItemId
WHEN ItemTypeId IN (0, 2, 3) THEN APT.CRID
END AS Parent
,CASE WHEN [Date worked] > @newrate THEN 'NewRate' ELSE 'OldRate' END AS Rate
FROM staging ST INNER JOIN
Reporting.dbo.annpremtest APT ON ST.CConcatex = APT.CConcatex
@newrate is a date.
The reason I'm asking is that I'm getting some output with 'OldRate' assigned when I know that only 'NewRate' should apply.
Can anyone see anything wrong with what I'm trying to do?