Use test
select t2.col_1, sum(t2.col_a)as COL_A,sum(t2.col_b)as COL_B,sum(t2.col_c)as COL_C
from
(
select t.col_1,
case t.name when 'a' then t.col_2 else 0 end as col_a,
case t.name when 'b' then t.col_2 else 0 end as col_b,
case t.name when 'c' then t.col_2 else 0 end as col_c
from
(
select col_1,name,avg(col_2)as col_2 from Result group by col_1,name
)as t)
)as t2
group by t2.col_1
SQL case关键字
最新推荐文章于 2023-09-12 09:58:57 发布