SQL Where statement with case doesn't print any record -
i'm trying create sql query has statement. in statement, want check clause. query shown below:
select * new_payment new_totalprofit>@totalprofit , (rtrim(ltrim(left(p.new_name ,(charindex('-',p.new_name)-1)))) = case when @paymenttype<>'all' @paymenttype end)
i checked there existing records in query no records showing. missing?
your case
look returning null
if @paymenttype
equal all
, , you'll no results. don't need case
expression:
select * new_payment new_totalprofit>@totalprofit , ( @paymenttype='all' or (rtrim(ltrim(left(p.new_name ,(charindex('-',p.new_name)-1)))) = @paymenttype) )
sql
No comments:
Post a Comment