select * from tb t where not exists (select * from tb where t.id=id and t.no>no)
select * from tb  where not exists (select * from tb t where t.id=id and t.no<no)

解决方案 »

  1.   

    select * from tb t where not exists (select * from tb where t.id=id and t.no>no)
    select * from tb where not exists (select * from tb t where t.id=id and t.no<no)别名的位置不同,一个是内表,一个是外表,返回的值也不同
      

  2.   

    select * from tb t where not exists (select * from tb where t.id=id and t.no>no)
    ---------
    相同id取最小的noselect * from tb where not exists (select * from tb t where t.id=id and t.no<no)
    ---------
    相同id取最大的no
      

  3.   

    第一条求id相同,no的最小值
    第二条求id相同,no的最大值
      

  4.   

    按石头大哥说的
    select * from tb where not exists (select * from tb t where t.id=id and t.no<=no)
    要<=就一样的了
      

  5.   

    第一条求id相同,no的最小值
    第二条也是求id相同,no的最小值
      

  6.   

    select * from tb t where not exists (select * from tb where t.id=id and t.no>no)
    ---子查询中的id与外面tb的ID比较 子查询中的no比外面的小 所以是取重复值中的no最小的那个
    select * from tb where not exists (select * from tb t where t.id=id and t.no<no)