sql server2005id ispound weight pound
----------------------------
1 1 14 10
2 0 12 13
3 1 14 13
4 0 11 15
5 0 15 16
求一语句,根据ispound判断选用哪个属性(weight,Pound)
得出表
id weight
1 10
2 12
3 13
4 11
5 15
----------------------------
1 1 14 10
2 0 12 13
3 1 14 13
4 0 11 15
5 0 15 16
求一语句,根据ispound判断选用哪个属性(weight,Pound)
得出表
id weight
1 10
2 12
3 13
4 11
5 15
,case ispound when 1 then Pound else weight end as weight
from tab
select id,
case ispound when 1 then Pound else weight end as weight
from 表
(id int,ispound int, weight int, pound int)insert into T
select 1,1,14,10 union all
select 2, 0, 12, 13 union all
select 3, 1, 14, 13 union all
select 4, 0, 11, 15 union all
select 5, 0, 15, 16select id,a=(case ispound when 1 then pound else weight end) from tdrop table t