Select column in main query from sub query (derived table) -
519937May 24 2010 — edited May 25 2010Hi:
I have the following query - How do I select Tot_Atnd defined in the derived table
SELECT count(distinct c.prgm_id) AS "Total Completed", h.Tot_Atnd
FROM iplanrpt.vm_rpt_prgm c
INNER JOIN
*(SELECT PRGM_ID, SUM(CASE WHEN ATTENDED_IND = 'Y' THEN 1 ELSE 0 END) AS "Tot_Atnd" FROM iPlanrpt.VM_RPT_PRGM_ATND GROUP BY PRGM_ID) h*
ON c.PRGM_ID = h.PRGM_ID
*;*
Thanks