select t2.col1, nvl(num, 0) from 
(select r1, count(r1) num from t1 group by r1) t1,
(select col1 from (
select rownum col1 from dual where connect by rownum<n)) t2
where t2.col1=t1.r1(+)