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
select * from 表 where type='c' and parents=(select max(parents) from 表 where type='c')
--或:select * from 表 a inner join select p=max(parents) from 表 where type='c') b on a.parents=b.p where a.type='c'
看漏了一个条件: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
Select * from 表 a where parents=(select max(parents) from 表 where type = 'c' and type = a.type)
Select * from 表 a where not exists(select 1 from 表 where type = 'c' and type = a.type and a.parents<parents)
Select * from 表 where type='c' and parents=(Select max(parents) from 表 where type='c')
where parents=(select max(parents) from 表 where type = 'c'
and type = a.type)
where not exists(select 1 from 表 where type = 'c'
and type = a.type and a.parents<parents)