Reputation: 2628
I have the following query where I'm trying to return different values from a table based off the values of a bit variable.
Is there a way I can substitute the where condition to get that to work?
DECLARE @isAggregate bit = 0
SELECT
*
FROM
Fields
WHERE
FieldType
CASE
WHEN @isAggregate = 1 THEN = 'Aggregate'
WHEN @isAggregate = 0 THEN <> 'Aggregate'
END
Upvotes: 1
Views: 967
Reputation: 50173
You can use boolean logic, case expression
will not work in this way :
where (@isAggregate = 1 and FieldType = 'Aggregate') or
(@isAggregate = 0 and FieldType <> 'Aggregate')
Upvotes: 4