All pastes #2087793 Raw Edit

Stuff

public text v1 · immutable
#2087793 ·published 2011-10-07 20:57 UTC
rendered paste body
select 
sum(case when timetype in ('No Action','Verify','Support') then hours else 0 end) 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.id,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 not in (select issue from issue_customer where customer in ('DEV','QA'))
	and ji.type = 1
	and wl.author in (select resource from resource)
	and wl.startdate >= '04/02/2011'
	and wl.startdate <= '07/01/2011'
) 
UNION
(
	select wl.id, wl.hours, 'Support' as timetype
	from worklog wl
	where wl.issue in (select supportissue from customer)
	and wl.author in (select resource from resource)
	and wl.startdate >= '04/02/2011'
	and wl.startdate <= '07/01/2011'
) ) timetypehours