mssql如何只显示有重复的数据呢?
有重复的数据就显示一条重复的数据,没重复的不显示,查询语句该怎么写呢?谢谢

解决方案 »

  1.   

    select * from tablename where id in (
    select id from tablename 
    group by id 
    having count(id) > 1
    )
      

  2.   

    select distinct * from tablename where id in ( 
    select id from tablename 
    group by id 
    having count(id) > 1 
    )
      

  3.   

    select distinct * 
      from tablename 
     where id in ( 
                  select id from tablename 
                  group by id 
                  having count(id) > 1 
                 )
      

  4.   

    SELECT DISTINCT Top(100) xx,tt FROM table或者参考
    http://blog.csdn.net/ZOU_SEAFARER/archive/2009/09/25/4592519.aspx