Reputation: 53
SELECT *
FROM T1 INNER JOIN T2 ON T1.C1 = T2.C1
WHERE
( (T1.C3-T2.C3<>0 )
And (CASE WHEN T1.C4 <> T2.C4 THEN 'Changed' END) )
OR
( (T1.C5-T2.C5<>0 )
And (T1.C6-T2.C6<>0) )
This is giving me an error ->
An expression of non-boolean type specified in a context where a condition is expected, near ')'.
What is wrong with this statement??
Upvotes: 0
Views: 40
Reputation: 891
Looking at your Case statement in the were clause, the case statement isn't compared to any value.
I would suggest moving your case statement into the select statement, or making sure you have a value to compare the case statement to.
ie:
declare @Changed nvarchar(50) = 'Changed'
in the where clause:
@Changed = (CASE WHEN T1.C4 <> T2.C4 THEN 'Changed' END) )
Upvotes: 0
Reputation: 499002
This is probably the cause:
And (CASE WHEN T1.C4 <> T2.C4 THEN 'Changed' END) )
You are doing an AND
on something that can return Changed
, which is not a boolean value.
Upvotes: 4