select
sum(hours) as "Total Hours",
sum(case when timetype in ('No Action','Verify') then hours else 0 end) as "NAR Hours",
sum(case when timetype in ('Support') then hours else 0 end) as "Support Hours",
sum(case when timetype in ('Maintenance') then hours else 0 end) as "Maintenance Hours"
from
((
select wl.hours,
(case when ji.resolution not in (-1,1) then 'No Action' when wl.verify = 1 then 'Verify' else 'Maintenance' end) as timetype
from worklog wl
join jiraissue ji on wl.issue = ji.id
where wl.issue in (select issue from issue_customer where customer not in ('DEV','QA'))
and ji.type = 1
and wl.author in (select resource from resource)
and wl.startdate >= '04/02/11'
and wl.startdate <= '07/01/2011'
)
UNION
(
select wl.hours, 'Support' as timetype
from worklog wl
where wl.issue in (select issue from issue_customer)
and wl.author in (select resource from resource)
and wl.startdate >= '04/02/11'
and wl.startdate <= '07/01/2011'
) ) timetypehours