select sum(case when wgrp_id='2' then quota end) w2, sum(case when wgrp_id='3' then quota end) w3, mmfrom tablegroup by mm