Group by + CaseWhen 怎么实现 返回
SqlSugar
老数据
3
1435
悬赏:5 飞吻
类似这样的查询
select userId
,sum(case when type= 0 then Count else 0 end) as num0
,sum(case when Type= 1 then Count else 0 end) as num1
,sum(case when Type= 2 then Count else 0 end) as num2
from usertool
group by userId
热忱回答(3)
-
fate stay night VIP0
2020/11/13sqlsufnc.xxsum( sqlfunc.if xxx else end
)
0 回复 -
恭禧、發財 VIP0
2020/11/13@fate stay night:这样写报异常呢,直接写SqlFunc.AggregateSum(s.Count)就可以的
0 回复 -
fate stay night VIP0
2020/11/13@恭禧、發財:已修复 近期发布
0 回复