<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 分组依据和其他列的总和值

      时间:2023-05-24

        <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 分组依据和其他列的总和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:MySql 单表,选择过去 7 天并包含空行 下一篇:MySQL 数据库中列名中的连字符

                相关文章

              • <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'>