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

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

                相关文档推荐

                ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                SQL query to group by day(按天分组的 SQL 查询)
                What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                Include missing months in Group By query(在 Group By 查询中包含缺失的月份)

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