【问题标题】:QUERY: sum two columns and order by one in Google SheetsQUERY:将两列相加并在 Google 表格中按一排序
【发布时间】:2020-10-20 16:23:53
【问题描述】:

我有以下数据集:

Country         Points    Bonus_Points
---------------------------------------
United States   1         50
Brazil          3         50
France          7         30
United States   2         25  

现在想查询该数据集并创建一个具有以下结果的列表,其中奖励积分和积分得到总结,并且列表按奖励积分排序。

Country         Points    Bonus_Points
---------------------------------------
United States   3         75
Brazil          3         50
France          7         30

=QUERY(A1:C,"select A, B, sum(C) group by A, B order by sum(C) desc", 1)

我能够对一列求和,但不知何故也无法获得 B/点的总和。 有什么想法吗?

【问题讨论】:

    标签: google-sheets google-sheets-formula


    【解决方案1】:

    看看有没有帮助

    =QUERY(A1:C,"select A, sum(B), sum(C) group by A order by sum(C) desc label sum(B) 'Points', sum(C) 'Bonus_Points'", 1)
    

    【讨论】:

    • 谢谢!为什么 =QUERY(A1:C,"select A, D, sum(B), ... 当 D 类似于评论或者我想在总和之外显示时,为什么不添加另一列?跨度>
    • 应该,但你也必须将它添加到 group by 子句中:group by A, D
    • 谢谢,忘记加了:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-26
    • 1970-01-01
    • 1970-01-01
    • 2014-12-09
    • 1970-01-01
    相关资源
    最近更新 更多