日期:2014-05-18 浏览次数:20485 次
select (case when ACTIONTYPE='更新' then (select GUISHUZUZHI from table_name where FORM_NO=192) else (select AFTERUPZUZHI from table_name where FORM_NO=192) end) as '更新后组织' from table_name where FORM_NO=192
select (case when ACTIONTYPE='更新' then 1 else 0 end) as '更新后组织' from table_name where FORM_NO=192
select (case when ACTIONTYPE='更新' then GUISHUZUZHI else AFTERUPZUZHI end) as '更新后组织' from table_name where FORM_NO=192
------解决方案--------------------
我有一张表 表中有三个字段 a,b,c当c字段等于某个值时 查询得到 a字段的值 其他情况就查询到b字段的值
下面有一个例子(报错):
--
select * from tb where (c = '某个值' and a = ...) or (c <> '某个值' and b = ... )
------解决方案--------------------
select (case when a.GiftType='1' then (select GiftName from tablename where GiftId=a.GiftId)
else (select GiftId from tablename where GiftId=a.GiftId) end) aaa from tablename a where a.GiftId='001'