Select value if condition in SQL Server
This question already has an answer here:
尝试案例
SELECT stock.name,
CASE
WHEN stock.quantity <20 THEN 'Buy urgent'
ELSE 'There is enough'
END
FROM stock
Have a look at CASE statements
http://msdn.microsoft.com/en-us/library/ms181765.aspx
上一篇: 选择语句中的布尔逻辑