Select * from 表 a 
where type = 'c' 
and parents in (Select max(parents) from 表 where type = a.type)

解决方案 »

  1.   

    select * from tableaname a ,(select type,max(parents) as tp from tablename group by type) b where a.type=b.type and a.parents=b.tp
      

  2.   

    select * from 表 where type='c' and parents=(select max(parents) from 表 where type='c')
      

  3.   

    --或:select * from 表 a inner join select p=max(parents) from 表 where type='c') b on a.parents=b.p where a.type='c'
      

  4.   

    看漏了一个条件:type='c',补充一下:select * from tableaname a ,(select type,max(parents) as tp from tablename where [type]='c' group by type) b where a.type=b.type and a.parents=b.tp
      

  5.   

    Select * from 表 a 
    where parents=(select max(parents)  from 表  where type = 'c' 
    and type = a.type)
      

  6.   

    Select * from 表 a 
    where not exists(select 1  from 表  where type = 'c' 
    and type = a.type and a.parents<parents)
      

  7.   

    Select * from 表 where type='c' and parents=(Select max(parents) from 表 where type='c')