tsql - How to use case clause in where condition using SQL Server? -
hi going filter 1 query in sql server. getting error thing
incorrect syntax near '='.
i have 1 table. in table store 2 column 1 socialtype , 2 isfuser this. want filter on 2 column.my filter param all,instagram,isfuser. need select want data. after select instagram instagramusers. this.
here query.
declare @filter nvarchar(max) = 'instagram' select * users isdeleted = 0 , @filter = case when @filter = 'instagram' socialtype when @filter = 'isfuser' (isfuser = 1) else @filter = 'all' (1 = 1) end
this query want apply filter how can have no idea. getting error.
you expand condition to:
declare @filter nvarchar(max) = 'instagram'; select * users isdeleted = 0 , ( (@filter = 'instagram' , socialtype = 'instagram') or (@filter = 'isfuser' , ifuser = 1) or @filter = 'all' );
Comments
Post a Comment