我有一张这样的桌子
Name Value
test 1
test 1
test 2
test 3
如何获得这样的东西?
Name 1 2 3
test 2 1 1
答案 0 :(得分:1)
检查此
select
name,
sum(IIF(Value=1, 1,0)) as c1,
sum(IIF(Value=2, 1,0)) as c2,
sum(IIF(Value=3, 1,0)) as c2
from t
group by name