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

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

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

        在两个字段上使用 group by 并在 SQL 中计数

        时间:2023-06-02
          <tbody id='G5SAk'></tbody>
        <tfoot id='G5SAk'></tfoot>
          <bdo id='G5SAk'></bdo><ul id='G5SAk'></ul>

            <legend id='G5SAk'><style id='G5SAk'><dir id='G5SAk'><q id='G5SAk'></q></dir></style></legend>

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

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

                  本文介绍了在两个字段上使用 group by 并在 SQL 中计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的 mysql 数据库中有一个表,它有两列:组和子组.见下文.

                   组,子组grp-A, sub-Agrp-A, sub-Agrp-A, sub-Bgrp-B, sub-Agrp-B, sub-Bgrp-B, sub-B

                  我正在尝试获取每个唯一情侣组/子组的记录数.

                  这是我所期望的:

                  组、子组、计数grp-A, sub-A, 2grp-A, sub-B, 1grp-B, sub-A, 1grp-B, sub-B, 2

                  在阅读了一些帖子后,我尝试了使用 group by、count() 的几个 sql 查询,但我没有得到预期的结果.我该如何解决这个问题?

                  解决方案

                  我想你在找:SELECT a, b, COUNT(a) FROM tbl GROUP BY a, b>

                  I have a table in my mysql db that has two columns: group and subgroup. See below.

                   group, subGroup
                   grp-A, sub-A
                   grp-A, sub-A
                   grp-A, sub-B      
                   grp-B, sub-A
                   grp-B, sub-B
                   grp-B, sub-B
                  

                  I am trying to get the number of records for each unique couple group/subGroup.

                  This is what I expect:

                  group, subGroup, count
                  grp-A, sub-A, 2
                  grp-A, sub-B, 1
                  grp-B, sub-A, 1
                  grp-B, sub-B, 2
                  

                  After reading some posts I tried several sql queries using group by, count(), but I do not manage to get the expected result. How can I fix this?

                  解决方案

                  I think you're looking for: SELECT a, b, COUNT(a) FROM tbl GROUP BY a, b

                  这篇关于在两个字段上使用 group by 并在 SQL 中计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:MySQL 中的 BIT 和 TINYINT 有什么区别? 下一篇:从一张表中选择不在另一张表中

                  相关文章

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

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