表:sampleImage 
字段:imgID,sphID(有重复) 如何查询出sphID不重复的结果,并且要从第2条开始显示??????????????? 

解决方案 »

  1.   

    select * from (select * from sampleImage s where not exists(select 1 from sampleImage where sphID=s.sphID and imgID>s.imgID)) t  where imgID
     not in ( select top 1imgID from ( select * from sampleImage s where not exists(select 1 from sampleImage where sphID=s.sphID and imgID>s.imgID))t)  
    --imgID自己選擇大小
      

  2.   

    表:sampleImage 
    字段:imgID,sphID(有重复) 如何查询出sphID不重复的结果,并且要从第2条开始显示??????????????? 
    ----------------------
    以什么 排序 ?
      

  3.   

    select distinct(sphID)
    from sampleImage  as s
    where s.sphID in (select top 1 distinct(sphID) from sampleImage)这个可能可以,你试试
      

  4.   

    select distinct(sphID)
    from sampleImage  as s
    where s.sphID not  in (select top 1 distinct(sphID) from sampleImage) 忘记写not 了