• <tfoot id='Z4vWT'></tfoot>

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

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

      <legend id='Z4vWT'><style id='Z4vWT'><dir id='Z4vWT'><q id='Z4vWT'></q></dir></style></legend>
          <bdo id='Z4vWT'></bdo><ul id='Z4vWT'></ul>
      1. 计算 DISTINCT 值的出现次数

        时间:2023-08-18
          <tbody id='TsIQw'></tbody>

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

          • <bdo id='TsIQw'></bdo><ul id='TsIQw'></ul>

            <tfoot id='TsIQw'></tfoot>

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

                  本文介绍了计算 DISTINCT 值的出现次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试查找一个 MySQL 查询,该查询将在特定字段中查找 DISTINCT 值,计算该值出现的次数,然后按计数对结果进行排序.

                  I am trying to find a MySQL query that will find DISTINCT values in a particular field, count the number of occurrences of that value and then order the results by the count.

                  示例数据库

                  id         name
                  -----      ------
                  1          Mark
                  2          Mike
                  3          Paul
                  4          Mike
                  5          Mike
                  6          John
                  7          Mark
                  

                  预期结果

                  name       count
                  -----      -----
                  Mike       3
                  Mark       2
                  Paul       1
                  John       1
                  

                  推荐答案

                  SELECT name,COUNT(*) as count 
                  FROM tablename 
                  GROUP BY name 
                  ORDER BY count DESC;
                  

                  这篇关于计算 DISTINCT 值的出现次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:比较日期范围 下一篇:从 MySQL 插入查询中获取新记录主键 ID?

                  相关文章

                  最新文章

                    • <bdo id='i1dyh'></bdo><ul id='i1dyh'></ul>

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

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

                    <tfoot id='i1dyh'></tfoot>

                    1. <legend id='i1dyh'><style id='i1dyh'><dir id='i1dyh'><q id='i1dyh'></q></dir></style></legend>