日期:2014-05-18 浏览次数:20464 次
create table tb(a int ,b int,c int ,d as case when A=0 and B=1 and C=1 then 1 else 0 end) go insert into tb (a,b,c) values(0,1,1) insert into tb (a,b,c) values(0,2,1) insert into tb (a,b,c) values(0,1,2) insert into tb (a,b,c) values(1,1,1) insert into tb (a,b,c) values(2,1,1) select * from tb drop table tb /* a b c d ----------- ----------- ----------- ----------- 0 1 1 1 0 2 1 0 0 1 2 0 1 1 1 0 2 1 1 0 (所影响的行数为 5 行) */
------解决方案--------------------
------解决方案--------------------
select A,B,case C when A=1 and B=1 then D else C when A=2 and B=2 then E else C end as C,D,E from table --前提是D,E都要有数据。。。。