日期:2014-05-18  浏览次数:20507 次

sql 求助
SQL code
select 1 as a,case 2 when 2 then 3 else 4 end as b,1*b as c


我想在字段c上用前面处理好的b字段,怎么使用呢。百度上实在不知道该怎么描述。所以....

------解决方案--------------------


SQL code


select a,1*b as c from
(
select 1 as a,case 2 when 2 then 3 else 4 end as b from tab
) t

------解决方案--------------------
探讨
SQL code
select 1 as a,case 2 when 2 then 3 else 4 end as b,1*b as c


我想在字段c上用前面处理好的b字段,怎么使用呢。百度上实在不知道该怎么描述。所以....

------解决方案--------------------
SQL code

;with temp as(select 1 as a,case 2 when 2 then 3 else 4 end  as b)
select temp.*,temp.b * 1 as c from temp