Group by + CaseWhen 怎么实现 返回

SqlSugar 老数据
3 1435

类似这样的查询

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