sql switch/case 'where' clause
i attempted poison around, nonetheless i couldn't anything assistance me out.
i'm perplexing sql:
declare @locationtype varchar(50);
declare @locationid int;
select column1, column2
from viewwhatever
where
case @locationtype
'location' following account_location = @locationid
'area' following xxx_location_area = @locationid
'division' following xxx_location_division = @locationid
i know i shouldn't have put '= @locationid' during finish any one, nonetheless i can't syntax even tie being correct. sql keeps angry '=' initial line...
how i this?
Comments
Post a Comment