I've created this:
SELECT
c.ProjectID,
Count(c.ID) as 'Registrants',
Count(dt.Hits) as 'Submissions'
FROM
CME_TBL c
JOIN
(SELECT ProjectID, Count(*) as Hits FROM CME_TBL
WHERE evalDate Is Not NULL OR testDate Is Not NULL
GROUP BY ProjectID
) dt
ON c.ProjectID = dt.ProjectID
GROUP BY
c.ProjectID
ORDER BY
c.ProjectID
and I get this:
ProjectID Registrants Submissions
--------- ----------- -----------
adv_1046 99 99
adv_1047 185 185
adv_1105 66 66
boh_1071 34 34
Instead, I want this:
ProjectID Registrants Submissions
--------- ----------- -----------
adv_1046 99 14
adv_1047 185 82
adv_1105 66 17
boh_1071 34 12
The "ProjectID" and "Submission s" columns are produced when I run the
derived table (dt, above) as a standalone query. By the same token,
the "Project ID" and "Registrant s" columns are produced when I run the
"outer" query, above.
Am I on the right track here?
TIA,
-- Bill
SELECT
c.ProjectID,
Count(c.ID) as 'Registrants',
Count(dt.Hits) as 'Submissions'
FROM
CME_TBL c
JOIN
(SELECT ProjectID, Count(*) as Hits FROM CME_TBL
WHERE evalDate Is Not NULL OR testDate Is Not NULL
GROUP BY ProjectID
) dt
ON c.ProjectID = dt.ProjectID
GROUP BY
c.ProjectID
ORDER BY
c.ProjectID
and I get this:
ProjectID Registrants Submissions
--------- ----------- -----------
adv_1046 99 99
adv_1047 185 185
adv_1105 66 66
boh_1071 34 34
Instead, I want this:
ProjectID Registrants Submissions
--------- ----------- -----------
adv_1046 99 14
adv_1047 185 82
adv_1105 66 17
boh_1071 34 12
The "ProjectID" and "Submission s" columns are produced when I run the
derived table (dt, above) as a standalone query. By the same token,
the "Project ID" and "Registrant s" columns are produced when I run the
"outer" query, above.
Am I on the right track here?
TIA,
-- Bill
Comment