I have multiple subqueries for groups of students (a,b,c) and I want to display the results by subject. Some groups may not be in certain subjects.
I'm receiving a 'divide by zero' error when performing a calculation. How can I modify the code below to display 'null' when the result is n/a?
STR(((100.0*COUNT(a.STC_grade))/SUM(COUNT(a.STC_grade))OVER(partition by dbo.S85_STUDENT_ACAD_CRED.stc_subject)), 5,0) +'%' AS 'PERCENT'
Any assistance would be appreciated.
If you added input data, your query and what your expectation were, it would be easies to recreate your situation. Not sure that my example fully covers your input data but I could get your error and fix it by adding
isnullinSUM(COUNT(isnull(sg.STC_grade,0)))Highlighted rows from the screen above will ruin the query below without
isnull.