SQL SELECT If (a = "") Then change the value of b

This seems like a simple question, but I could not find the answer. I am basically trying to do this:

SELECT * FROM table1 IF(columnA > 0) BEGIN columnB = 'Greater than 0' END 

I don’t want the value to change in the table, I just want it to change as a result. Any suggestions?

+6
source share
2 answers
 SELECT ColumnA , case when ColumnA > 0 then 'Greater than 0' else ColumnB END AS ColumnB FROM table1; 
+22
source

This should work:

 SELECT columnA, IIF(columnA > 0, 'Greater than 0', columnB) FROM table1; 
+6
source

All Articles