this question has answer here:
- how perform if…then in sql select? 22 answers
- sql returning custom values based on query results 2 answers
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
Post a Comment