sql server - SQL where clause with multiple condition -

in data base table have value above image.
i want check conditions in clause.
i want check url
demoorpaid=paid , validupto=null => return 12.demoorpaid=paid , validupto=(not null) compare current date , check if validupto<=getdate() => return 1demoorpaid=demo , validupto=null => return 0demoorpaid=demo , validupto=(not null) compare current date , check if validupto<=getdate() => return 0
if want return computed column, can use this:
select case when demoorpaid = 'paid' , validupto null 1 when demoorpaid = 'paid' , validupto not null , validupto <= getdate() 1 when demoorpaid = 'demo' , validupto null 1 else 0 end it's bit unclear want return in cases not covered conditions.
Comments
Post a Comment