您的位置:首页 > 其它

行转列求和:不加 in 条件,sum的数据会不会准确?

2015-09-24 17:17 176 查看
我的习惯写法,担心不加 in 条件 ,统计结果会包含其他的数据

create table zy
(
F01 varchar(4),
F02 int
)

insert into zy
select 'A',10
union all
select 'B',10
union all
select 'C',10
union all
select 'D',10
union all
select 'E',10

select
sum(case F01 when 'A' then F02 end) A,
sum(case F01 when 'B' then F02 end) B
from zy


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: