标准条件聚合:
select city,
sum(case when active = 'true' then 1 else 0 end) active,
sum(case when blacklist = 'true' then 1 else 0 end) blacklist,
sum(case when license = 'true' then 1 else 0 end) license,
sum(case when married = 'true' then 1 else 0 end) married
from TableName
group by city
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
63 次 |
| 最近记录: |