select No,sum(select days from table1 where type=a) as a,sum(select days from table1 where type=a) as a,sum(select days from table1 where type=b) as b,     sum(select days from table1 where type=b) as b,sum(days) from table1 group by No