【发布时间】:2022-11-25 14:58:10
【问题描述】:
哪个查询脚本总结每个客户的每一行?
以下是示例;
| customer | car | truck | 4WD |
|---|---|---|---|
| Albert | 2 | 0 | 0 |
| Joe | 0 | 0 | 1 |
| Catherine | 1 | 0 | 0 |
| Mark | 3 | 0 | 1 |
像这样输出以总结总数;
| customer | has_item |
|---|---|
| Albert | 2 |
| Joe | 1 |
| Catherine | 1 |
| Mark | 4 |
非常感谢
我试过了
SUM(CASE when xx then x else x end) 语句 = which output wrong sum total
sum(rownum) = 也不起作用
【问题讨论】: