lundi 23 avril 2018

SQL update query with IF ELSE

How do I write the following SQL Query (SSMS)

My Table has 2 columns - ColumnA and ColumnB

IF my_table.columnA < 15
  update my_table set my_table.ColumnB = 0
else IF my_table.columnA < 28
  update my_table set my_table.columnB = 1
else IF my_table.columnA < 43
  update my_table set my_table.columnB = 2
else IF my_table.columnA < 60
  update my_table set my_table.columnB = 3

Thanks for your help!

Aucun commentaire:

Enregistrer un commentaire