All pastes #2088754 Raw Edit

Untitled

public text v1 · immutable
#2088754 ·published 2011-10-10 16:38 UTC
rendered paste body
select SUM(hours) from (
select syear,squarter,smonth,customer,author, hours, timetype, 
(case when timetype in ('No Action','Verify') then hours else 0 end) as "NAR Hours",
(case when timetype in ('Support') then hours else 0 end) as "Support Hours",
(case when timetype in ('Maintenance') then hours else 0 end) as "Maintenance Hours"
from(
select wl.syear, wl.squarter, wl.smonth, ci.customer, wl.author, sum(wl.hours) as hours, (case when ji.resolution not in (-1,1) then 'No Action' when wl.verify = 1 then 'Verify' else 'Maintenance' end) as timetype

from jiraissue ji
join worklog wl
on ji.id = wl.issue
join (select issue, (case when customer like 'Bring%' then 'Bring' else customer end) as customer from issue_customer) ci
on ji.id = ci.issue
where 
wl.author in (select resource from resource)
and ji.type = 11
and wl.startdate >= '04/02/11'
and wl.startdate <= '07/01/2011'

group by wl.syear, wl.squarter, wl.smonth, ci.customer, wl.author, (case when ji.resolution not in (-1,1) then 'No Action' when wl.verify = 1 then 'Verify' else 'Maintenance' end)
) innserselect1
) t2