100.0 * CAST(
SUM(CASE WHEN ap.completed = 'N' THEN 1.0 ELSE 0.0 END) AS float)
where academy_period_id = 24)
FROM Xref_academy_Period x
INNER JOIN Academy_Profiles AP ON ap.academy_id = x.academy_id
AND ap.academy_period_id = 24
I am trying to take the number(sum of) of records that have a value of "N" in this column and divide it by the total count of a query on another table (the xref_academy_profile_period table). I think and well, I know my syntax is wrong or I am at least not getting the expected result.
Any help appreciated