È¡ ÁÐA=a1ÀïÁÐB×î´óµÄ ÁÐA=a2ÀïÁÐB×î´óµÄ ¡£¡£¡£¡£select a ,max(b) as maxb from table group by a select a, max(b) from tb group by a
Áкܶࡣ ÎÒÏëд select * ÄØ£¿ SQL code: select a ,max(b) as maxb from table group by a
ÓÃgroup by ¾Í²»ÄÜÓÃ* Ò²¾ÍÊÇ˵³ýÁË group by ûÓбðµÄ°ì·¨£¿ Â¥ÉÏÕý½â SQL code: with Table_A as (
select 'a1' a ,1 b from dual union all select 'a1' a ,2 b from dual union all select 'a1' a ,3 b from dual union all select 'a2' a ,1 b from dual union all select 'a2' a ,2 b from dual union all select 'a3' a ,1 b from dual union all select 'a4' a ,2 b from dual
)
SELECT * from Table_A t1 WHERE EXISTS (SELECT t2.a, max(t2.b) from Table_A t2 WHERE t2.a=t1.a GROUP BY t2.a)