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

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

        How do I find duplicates across multiple columns?(如何在多列中查找重复项?)

          <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
                  

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

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

                  相关文档推荐

                  Building a comma separated list?(建立一个逗号分隔的列表?)
                  Errors in SQL Server while importing CSV file despite varchar(MAX) being used for each column(尽管每列都使用了 varchar(MAX),但在导入 CSV 文件时 SQL Server 中出现错误)
                  How can I import an Excel file into SQL Server?(如何将 Excel 文件导入 SQL Server?)
                  Export table to file with column headers (column names) using the bcp utility and SQL Server 2008(使用 bcp 实用程序和 SQL Server 2008 将表导出到带有列标题(列名称)的文件)
                  Concat field value to string in SQL Server(将字段值连接到 SQL Server 中的字符串)
                  SQL Server Bulk insert of CSV file with inconsistent quotes(SQL Server 批量插入带有不一致引号的 CSV 文件)
                  <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>

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

                          • <legend id='TuPfy'><style id='TuPfy'><dir id='TuPfy'><q id='TuPfy'></q></dir></style></legend>