sql server - SQL where clause with multiple condition -


enter image description here

in data base table have value above image.

i want check conditions in clause.

i want check url

  1. demoorpaid=paid , validupto=null => return 1 2.demoorpaid=paid , validupto=(not null) compare current date , check if validupto<=getdate() => return 1
  2. demoorpaid=demo , validupto=null => return 0
  3. demoorpaid=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

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -