I'm trying to build a query selecting two columns (category types) from one table JOINED to another table-column displaying average grades as percentage number-types; here is my first attempt:
SELECT gt.grade_type_code,
gt.description,
gg.numeric_grade
FROM student.grade_type gt
JOIN student.grade gg ON gt.grade_type_code = gg.GRADE_TYPE_CODE;
Here is a screenshot of output for clarification:
My second attempt is closer to the expected result, sans "DESCRIPTION" column, necessitating the JOIN clause; I've also included the query and output below:
SELECT grade_type_code,
count(grade_type_code),
Round(avg(numeric_grade),2)
FROM student.grade
GROUP BY grade_type_code
ORDER BY GRADE_TYPE_CODE;
Lastly, here is my most recent attempt to combine the above logic:
SELECT gt.grade_type_code,
gt.description,
round(avg(gg.numeric_grade),2)
FROM student.grade_type gt
JOIN student.grade gg ON gt.grade_type_code = gg.GRADE_TYPE_CODE
GROUP BY gt.grade_type_code
ORDER BY gt.grade_type_code;
And the error message:
ORA-00979: not a GROUP BY expression
00979. 00000 - "not a GROUP BY expression"
*Cause:
*Action:
Error at Line: 1 Column: 28
So essentially, I'm attempting to display the average NUMERIC_GRADE for the correspondingly grouped category types (i.e. Participation = avg percentage) but my GROUP_BY
attempts invariably return errors (not sure why). I believe my logic is directionally correct, albeit flawed; could someone please advise? Thank you!