【问题标题】:grand total in ORACLE SQL query?ORACLE SQL查询中的总计?
【发布时间】: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) = 也不起作用

【问题讨论】:

    标签: oracle-sqldeveloper


    【解决方案1】:

    只是

    select customer,
           car + truck + "4WD" as has_item
    from your_table
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-25
      • 2010-11-04
      • 1970-01-01
      • 2023-01-17
      • 2019-11-24
      • 1970-01-01
      相关资源
      最近更新 更多