break on report
compute sum of cnt20 on report
compute sum of cnt40 on report
compute sum of cnt45 on report
select d.userid,nvl(a.cnt20,0) cnt20,
nvl(b.cnt40,0) cnt40,
nvl(c.cnt45,0) cnt45
from
(select userid,count(*) cnt20 from table
group by userid where tons = 20) a,
(select userid,count(*) cnt40 from table
group by userid where tons = 40) b,
(select userid,count(*) cnt45 from table
group by userid where tons = 45) c,
select distinct userid from table d
where d.userid = a.userid(+)
and d.userid = b.userid(+)
and d.userid = c.userid(+)