SELECT Year(scrStart.statusDate), quarter(scrStart.statusDate), count(DISTINCT totEnd.PROD_APP_ID) as totalApps, (datediff(scrEnd.statusDate, scrStart.statusDate)) as 'screening', 
avg(datediff(totEnd.statusDate, revStart.statusDate)) as 'review', avg(datediff(totEnd.statusDate, scrStart.statusDate)) as 'total'
 FROM pdx_na.timeline totEnd
JOIN pdx_na.timeline scrStart on totEnd.PROD_APP_ID = scrStart.PROD_APP_ID  and scrStart.regState='VERIFY'
LEFT JOIN pdx_na.timeline scrEnd on totEnd.PROD_APP_ID = scrEnd.PROD_APP_ID and scrEnd.regState='SCREENING'
LEFT JOIN pdx_na.timeline revStart on totEnd.PROD_APP_ID = revStart.PROD_APP_ID and revStart.regState='REVIEW_BOARD'
where totEnd.regState='REGISTERED' or totEnd.regState='REJECTED'
Group by Year(scrStart.statusDate), quarter(scrStart.statusDate)