1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| With MaTable AS
(
select to_date('01/01/2010', 'dd/mm/yyyy') as dt, 'A' as tp from dual union all
select to_date('15/01/2010', 'dd/mm/yyyy') , 'A' from dual union all
select to_date('11/02/2010', 'dd/mm/yyyy') , 'A' from dual union all
select to_date('02/03/2010', 'dd/mm/yyyy') , 'B' from dual union all
select to_date('15/03/2010', 'dd/mm/yyyy') , 'B' from dual union all
select to_date('16/03/2010', 'dd/mm/yyyy') , 'A' from dual
)
select to_char(dt, 'mm/yyyy') as mois,
count(case tp when 'B' then 1 end) as nb_b
from MaTable
group by to_char(dt, 'mm/yyyy'), to_char(dt, 'yyyymm')
order by to_char(dt, 'yyyymm') asc;
MOIS NB_B
01/2010 0
02/2010 0
03/2010 2 |
Partager