<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 按组计数出现次数

      Mysql count occurrence by group(Mysql 按组计数出现次数)
        <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 按组计数出现次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)(超出最大存储过程、函数、触发器或视图嵌套级别(限制 32))
                How to View Oracle Stored Procedure using SQLPlus?(如何使用 SQLPlus 查看 Oracle 存储过程?)
                How to debug stored procedure in VS 2015?(如何在 VS 2015 中调试存储过程?)
                Set the variable result, from query(设置变量结果,来自查询)
                What is dynamic SQL?(什么是动态 SQL?)
                Mysql - How to quit/exit from stored procedure(Mysql - 如何退出/退出存储过程)

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

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

                        <tbody id='Unsq3'></tbody>

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