如何执行if…然后在SQL选择中?如何执行IF...THEN在SQL SELECT口供?例如:SELECT IF(Obsolete = 'N' OR InStock = 'Y' ? 1 : 0) AS Saleable, * FROM Product
3 回答
MM们
TA贡献1886条经验 获得超2个赞
CASE
SELECT CAST( CASE WHEN Obsolete = 'N' or InStock = 'Y' THEN 1 ELSE 0 END AS bit) as Saleable, *FROM Product
CAST
int
SELECT CASE WHEN Obsolete = 'N' or InStock = 'Y' THEN 1 ELSE 0 END as Saleable, *FROM Product
CASE
CASE
SELECT IIF(Obsolete = 'N' or InStock = 'Y', 1, 0) as Saleable, * FROM Product
斯蒂芬大帝
TA贡献1827条经验 获得超8个赞
SELECT CASE <variable> WHEN <value> THEN <returnvalue> WHEN <othervalue> THEN <returnthis> ELSE <returndefaultcase> END AS <newcolumnname>FROM <table>
SELECT CASE WHEN <test> THEN <returnvalue> WHEN <othertest> THEN <returnthis> ELSE <returndefaultcase> END AS <newcolumnname>FROM <table>
添加回答
举报
0/150
提交
取消