表table1
id  nameselect top 1 from table1 a ,table1 b where a.name=b.name  //取重复数据中的第一条select a.* from table1 a where id=(select id from table1 where id=a.id)

解决方案 »

  1.   

    select a.* from table1 a where id=(select id from table1 where id=a.id)
    ????
      

  2.   


    select * from tb t where exists(
    select * from tb where id=t.id 
    goup by id
    having count(*)>1
    )
      

  3.   

    第一条语句: 返回一条 表a 与表b name相同的记录
    第二条语句:返回表a中 与表b id相同的数据集
      

  4.   

    select top 1 from table1 a ,table1 b where a.name=b.name  //取重复数据中的第一条select a.* from table1 a where id=(select top 1 id from table1 where id=a.id) //取重复数据中的第一条这两条语句有什么区别,为什么第一条的结果跟第二条不同
      

  5.   

    第一条:返回a表与b表中name相同的记录
    第二条:楼主确认语句没写错?貌似只取a表的记录.
      

  6.   

    第一个返回是的table1里有相同名称的第一条记录第二个ID要是不重复的话就是取整个表了
      

  7.   

    select top 1 from table1 a ,table1 b where a.name=b.name  //取重复数据中的第一条 
    这条语句如果要返回整个表重复数据的第一条,要怎么改呢?
      

  8.   

    select top 1 from table1 a ,table1 b where a.name=b.name  //取重复数据中的第一条 
    这条语句如果要返回整个表重复数据的第一条,要怎么改呢?
      

  9.   

    如果存在唯一的ID,
    select a.*
    from  table1 a
    where not exists(select 1 from table1 where name = a.name where id < a.id)
    如果不存在唯一的ID,在2000 生成带ID的临时表,2005可以用row_number()
      

  10.   

    select a.* 
    from  table1 a 
    where id = (select min(id) from table1 where name = a.name)