sql >> Base de Datos >  >> RDS >> Oracle

Consulta de grupo/recuento de Oracle

Prueba este (no lo he probado):

with t2 as (
    select  ColA2, ColB2, count(*) cnt 
    from TableTwo
    group by ColA2, ColB2 
)
select t1.Id1,
(  select max(cnt) MaxDup
   from t2
   where t2.ColA2=t1.Id1)
from TableOne t1