<i id='oKMJu'><tr id='oKMJu'><dt id='oKMJu'><q id='oKMJu'><span id='oKMJu'><b id='oKMJu'><form id='oKMJu'><ins id='oKMJu'></ins><ul id='oKMJu'></ul><sub id='oKMJu'></sub></form><legend id='oKMJu'></legend><bdo id='oKMJu'><pre id='oKMJu'><center id='oKMJu'></center></pre></bdo></b><th id='oKMJu'></th></span></q></dt></tr></i><div id='oKMJu'><tfoot id='oKMJu'></tfoot><dl id='oKMJu'><fieldset id='oKMJu'></fieldset></dl></div>

<small id='oKMJu'></small><noframes id='oKMJu'>

    <tfoot id='oKMJu'></tfoot>
    • <bdo id='oKMJu'></bdo><ul id='oKMJu'></ul>

      <legend id='oKMJu'><style id='oKMJu'><dir id='oKMJu'><q id='oKMJu'></q></dir></style></legend>

    1. MySQL 分组依据和其他列的总和值

      MySQL Group By and Sum total value of other column(MySQL 分组依据和其他列的总和值)

        <i id='JI20x'><tr id='JI20x'><dt id='JI20x'><q id='JI20x'><span id='JI20x'><b id='JI20x'><form id='JI20x'><ins id='JI20x'></ins><ul id='JI20x'></ul><sub id='JI20x'></sub></form><legend id='JI20x'></legend><bdo id='JI20x'><pre id='JI20x'><center id='JI20x'></center></pre></bdo></b><th id='JI20x'></th></span></q></dt></tr></i><div id='JI20x'><tfoot id='JI20x'></tfoot><dl id='JI20x'><fieldset id='JI20x'></fieldset></dl></div>

          <bdo id='JI20x'></bdo><ul id='JI20x'></ul>
            <tbody id='JI20x'></tbody>
        • <small id='JI20x'></small><noframes id='JI20x'>

          <tfoot id='JI20x'></tfoot><legend id='JI20x'><style id='JI20x'><dir id='JI20x'><q id='JI20x'></q></dir></style></legend>
              • 本文介绍了MySQL 分组依据和其他列的总和值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我有两列这样的:

                +----------+--------+
                |   word   | amount |
                +----------+--------+
                | dog      |      1 |
                | dog      |      5 |
                | elephant |      2 |
                +----------+--------+
                

                我想对金额求和,得到结果

                I want to sum the amounts, to get the result

                +----------+--------+
                | dog      |      6 |
                | elephant |      2 |
                +----------+--------+
                

                到目前为止我尝试过的(但失败了)是这样的:

                What I have tried so far (and failed) is this:

                SELECT word, SUM(amount) FROM `Data` Group By 'word'
                

                推荐答案

                删除 WORD 周围的单引号.它会导致列名转换为字符串.

                Remove the single quote around the WORD. It causes the column name to be converted as string.

                SELECT word, SUM(amount) 
                FROM Data 
                Group By word
                

                这篇关于MySQL 分组依据和其他列的总和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Can#39;t Create Entity Data Model - using MySql and EF6(无法创建实体数据模型 - 使用 MySql 和 EF6)
                MySQL select with CONCAT condition(MySQL选择与CONCAT条件)
                Capitalize first letter of each word, in existing table(将现有表格中每个单词的首字母大写)
                How to retrieve SQL result column value using column name in Python?(如何在 Python 中使用列名检索 SQL 结果列值?)
                Update row with data from another row in the same table(使用同一表中另一行的数据更新行)
                Exporting results of a Mysql query to excel?(将 Mysql 查询的结果导出到 excel?)

                  <tbody id='raUOe'></tbody>
              • <legend id='raUOe'><style id='raUOe'><dir id='raUOe'><q id='raUOe'></q></dir></style></legend>

                      <i id='raUOe'><tr id='raUOe'><dt id='raUOe'><q id='raUOe'><span id='raUOe'><b id='raUOe'><form id='raUOe'><ins id='raUOe'></ins><ul id='raUOe'></ul><sub id='raUOe'></sub></form><legend id='raUOe'></legend><bdo id='raUOe'><pre id='raUOe'><center id='raUOe'></center></pre></bdo></b><th id='raUOe'></th></span></q></dt></tr></i><div id='raUOe'><tfoot id='raUOe'></tfoot><dl id='raUOe'><fieldset id='raUOe'></fieldset></dl></div>
                        <bdo id='raUOe'></bdo><ul id='raUOe'></ul>
                        <tfoot id='raUOe'></tfoot>

                          <small id='raUOe'></small><noframes id='raUOe'>