我对两个查询使用相同的表和列,但我有不同的别名和 avg 函数。我如何能够将这两个查询与 UNION ALL 结合起来,因为我想要从它们中选择的每一行。显然,当我有不同的选择语句时,我不能这样做。我怎样才能结合这两个查询?
SELECT GRADE_TYPE_CODE, ROUND(TO_CHAR(NUMERIC_GRADE),2) AS GRADE
FROM GRADE
WHERE STUDENT_ID = 10 AND SECTION_ID = 5
ORDER BY GRADE_TYPE_CODE DESC,NUMERIC_GRADE DESC;
SELECT 'Average is:' AS GRADE_TYPE_CODE,AVG(GRADE) AS GRADE
FROM
(
SELECT AVG(NUMERIC_GRADE) AS GRADE
FROM GRADE
WHERE STUDENT_ID = 10 AND SECTION_ID = 5
GROUP BY GRADE_TYPE_CODE
) myInnerTable;