|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
[code=sql]select 时间 as 日期,姓名,'一级' as 代理类别,SUM(代理金额) as 代理金额
from tb
group by 时间,姓名
union all
select 时间 as 日期,姓名,代理类别,代理金额
from tb
where 代理类别 = '二级'
select 时间 as 日期,
SUM(case when 姓名 = 'A' then 代理金额 end) as A,
SUM(case when 姓名 = 'B' then 代理金额 end) as B,
SUM(case when 姓名 = 'C' then 代理金额 end) as C,
SUM(case when 姓名 = 'A' then 代理金额 end) as A,
SUM(case when 代理类别 = '一级' then 代理金额 end) as 一级,
SUM(case when 代理类别 = '二级' then 代理金额 end) as 二级,
SUM(代理金额) as 总计
from tb [/code] |
|