<bdo id='X6n5x'></bdo><ul id='X6n5x'></ul>
      <legend id='X6n5x'><style id='X6n5x'><dir id='X6n5x'><q id='X6n5x'></q></dir></style></legend>

    1. <tfoot id='X6n5x'></tfoot>

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

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

      Mysql 按组计数出现次数

      时间:2023-10-26
        <bdo id='3qHDw'></bdo><ul id='3qHDw'></ul>

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

              1. <small id='3qHDw'></small><noframes id='3qHDw'>

              2. <legend id='3qHDw'><style id='3qHDw'><dir id='3qHDw'><q id='3qHDw'></q></dir></style></legend>
                  <tbody id='3qHDw'></tbody>
                <tfoot id='3qHDw'></tfoot>
                本文介绍了Mysql 按组计数出现次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在 mysql 数据库上有下表.

                Hi i have following table on mysql DB.

                ╔═══════════╦═════════╦════════╦════════════════╗
                ║ REVIEW_ID ║ USER_ID ║ STATUS ║   DATE_ADDED   ║
                ╠═══════════╬═════════╬════════╬════════════════╣
                ║       218 ║       2 ║ cool   ║ 20130121134811 ║
                ║       218 ║       2 ║ cool   ║ 20130121134812 ║
                ║       218 ║       2 ║ lame   ║ 20130121134813 ║
                ║       218 ║       2 ║ funny  ║ 20130121134814 ║
                ║       218 ║       2 ║ funny  ║ 20130121134815 ║
                ║       218 ║       2 ║ funny  ║ 20130121134816 ║
                ║       218 ║       2 ║ lame   ║ 20130121134817 ║
                ╚═══════════╩═════════╩════════╩════════════════╝
                

                如何获得结果,当我根据 user_id 进行查询时,我需要获得每种类型的总状态结果:

                how can i get a result where when i do query based on user_id i need to get result of total status for each type:

                ╔════════╦════════════╗
                ║ STATUS ║ TOTALCOUNT ║
                ╠════════╬════════════╣
                ║ cool   ║          2 ║
                ║ funny  ║          3 ║
                ║ lame   ║          2 ║
                ╚════════╩════════════╝
                

                谢谢

                推荐答案

                使用COUNT()是一个聚合函数,根据状态进行分组>

                Use COUNT() which is an aggregate function, and group them according to their status

                SELECT  status, COUNT(*) totalCount
                FROM    tableName
                GROUP   BY status
                

                • SQLFiddle 演示
                • 其他

                  • MySQL GROUP BY 和一些聚合函数列表

                  这篇关于Mysql 按组计数出现次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:选择计数(*); 下一篇:MySQL :: 从逗号分隔的字符串中选择

                相关文章

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

              3. <legend id='Unsq3'><style id='Unsq3'><dir id='Unsq3'><q id='Unsq3'></q></dir></style></legend>
                  <bdo id='Unsq3'></bdo><ul id='Unsq3'></ul>

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