Select value if condition in SQL Server -


in query selection display result whether field satisfies condition.

imagine have table called stock. table has column tells me number of each item in stock.

what this:

select      stock.name, if (stock.quantity <20, "buy urgent", "there enough") stock 

is there function in sql server that?

try case

select   stock.name,       case           when stock.quantity <20 'buy urgent'          else 'there enough'       end stock 

Comments