• <small id='hLTLq'></small><noframes id='hLTLq'>

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

      <tfoot id='hLTLq'></tfoot>

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

        如何在多列中查找重复项?

        时间:2023-10-09

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

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

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

                  本文介绍了如何在多列中查找重复项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我想做类似下面这个sql代码的事情:

                  So I want to do something like this sql code below:

                  select s.id, s.name,s.city 
                  from stuff s
                  group by s.name having count(where city and name are identical) > 1
                  

                  要产生以下内容,(但忽略只有名称或只有城市匹配的地方,它必须在两列上):

                  To produce the following, (but ignore where only name or only city match, it has to be on both columns):

                  id      name  city   
                  904834  jim   London  
                  904835  jim   London  
                  90145   Fred  Paris   
                  90132   Fred  Paris
                  90133   Fred  Paris
                  

                  推荐答案

                  Duplicated id for pair name and city:

                  Duplicated id for pairs name and city:

                  select s.id, t.* 
                  from [stuff] s
                  join (
                      select name, city, count(*) as qty
                      from [stuff]
                      group by name, city
                      having count(*) > 1
                  ) t on s.name = t.name and s.city = t.city
                  

                  这篇关于如何在多列中查找重复项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:SELECT 查询中的默认行顺序 - SQL Server 2008 与 SQL 2012 下一篇:使用 SQL 检测连续的日期范围

                  相关文章

                  <tfoot id='TuPfy'></tfoot>

                  1. <small id='TuPfy'></small><noframes id='TuPfy'>

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

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

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