假设表T有个add_date 为date类型: select extract(month from add_date) the_month ,count(1) as record_count from t group by extract(month from add_date)
select x.the_month ,count(t.add_date) rec_count from ( select rownum the_month from t where rownum <= 12 connect by rownum<=12 ) x left outer join t on x.the_month = extract(month from T.add_date) group by x.the_month
select extract(month from add_date) the_month
,count(1) as record_count
from t
group by extract(month from add_date)
select x.the_month
,count(t.add_date) rec_count
from
(
select rownum the_month
from t
where rownum <= 12
connect by rownum<=12
) x
left outer join t
on x.the_month = extract(month from T.add_date)
group by x.the_month