1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
With TOTO AS
(
select 1 as id, 'x' as Val , to_date('01/08/2009', 'dd/mm/yyyy') as Dat3 from dual union all
select 1 , 'x' , to_date('15/08/2009', 'dd/mm/yyyy') from dual union all
select 1 , 'y' , to_date('17/08/2009', 'dd/mm/yyyy') from dual union all
select 1 , 'x' , to_date('18/08/2009', 'dd/mm/yyyy') from dual union all
select 1 , 'y' , to_date('19/08/2009', 'dd/mm/yyyy') from dual union all
select 1 , 'y' , to_date('20/08/2009', 'dd/mm/yyyy') from dual union all
select 2 , 'x' , to_date('01/08/2009', 'dd/mm/yyyy') from dual
)
select
max(id ) keep (dense_rank first order by count(*) desc) as id,
max(Val) keep (dense_rank first order by count(*) desc) as Val
from
TOTO
group by
id,
Val |
Partager