select col,count(col) from tbname group by col having count(col)>1

解决方案 »

  1.   

    以前用过类似的用法,忘了具体的了
    大概是下面的意思吧。
    select * from table where convert(varchar(30),convert(varchar(10),col1)+convert(varchar(10),col2)+convert(varchar(10),col3)) in (select convert(varchar(30),convert(varchar(10),col1)+convert(varchar(10),col2)+convert(varchar(10),col3)) from table group by convert(varchar(30),convert(varchar(10),col1)+convert(varchar(10),col2)+convert(varchar(10),col3)) having count(convert(varchar(30),convert(varchar(10),col1)+convert(varchar(10),col2)+convert(varchar(10),col3)))  > 1)
      

  2.   

    select distinct * from yourtable group by field1,field2...fieldn having (count(*) > 1)
      

  3.   

    --测试环境我也建好了use pubs 
    create table emp
    (
    ID char(3),
    name varchar(20),
    type int
    )use pubs insert into emp values('001','steven',5)
    use pubs insert into emp values('002','tom',8)
    use pubs insert into emp values('003','nelly',7)
    use pubs insert into emp values('001','steven',5)
    use pubs insert into emp values('004','sundy',4)
    use pubs insert into emp values('004','sundy',3)use pubs select * from emp order by id asc--use pubs drop table emp
      

  4.   

    alter table emp add temp_id int identity(1,1)
    godelete a from emp a
    where temp_id<>(select top 1 temp_id from emp where id=a.id order by type desc)
    alter table emp drop column temp_id
      

  5.   

    select * from emp order by id ascID   name                 type        
    ---- -------------------- ----------- 
    001  steven               5
    002  tom                  8
    003  nelly                7
    004  sundy                4(4 row(s) affected)
      

  6.   

    select * from a_table a where (select count(*) from a_table b where a.field = b.field) > 1
      

  7.   

    ID   name                 type        
    ---- -------------------- ----------- 
    001  steven               5
    002  tom                  8
    003  nelly                7
    004  sundy                4
    这种结果正是我想要的   !!!!
    可是,pressman(行者)   你的程序运行不了啊   运行有错误!! 能解释一下你的程序吗??
    能测试一下你的程序吗? 
    谢谢!!
      

  8.   

    简单:
    SELECT A FROM tab 
      GROUP BY A 
    HAVING COUNT(A) > 1
      

  9.   

    sdhylj(saber_blood)
    的我试了一下可以
    学习
      

  10.   

    select distinct
    这个关键自就可以实现你的要求