当前位置: 代码迷 >> Sql Server >> 小弟我傻了,被这种有关问题难倒
  详细解决方案

小弟我傻了,被这种有关问题难倒

热度:136   发布时间:2016-04-27 14:09:56.0
我傻了,被这种问题难倒
begin
if(1=1)
select '1'
else
select '2'
end

union all
select '3'


这里提示错误 我想先执行begin end 里面的 再union 后面的 怎么做啊

------解决方案--------------------
begin
if(1=1)
select '1'
union all
select '3'

else
select '2'
union all
select '3'

end



------解决方案--------------------
SQL code
select (case when 条件 then '1' else '3' end)union allselect '2'
  相关解决方案