Я думаю, что вы пытаетесь достичь
SELECT *
FROM BOOK
JOIN
(
SELECT BOOK_SUBJECT,
AVG(BOOK_COST) AS AVGCOST,
MIN(BOOK_COST) AS MINCOST,
MAX(BOOK_COST) AS MAXCOST
FROM BOOK
GROUP BY BOOK_SUBJECT
) AS SUB USING (BOOK_SUBJECT)
ORDER BY BOOK_TITLE;
Основано на
BOOK_SUBJECT BOOK_TITLE BOOK_COST
------------ ---------- ---------------------
MATHS Book 1 15.99
MATHS Book 2 14.99
MATHS Book 3 13.99
ENGLISH Book A 10.99
ENGLISH Book B 9.99
Возвращает
BOOK_SUBJECT BOOK_TITLE BOOK_COST AVGCOST MINCOST MAXCOST
------------ ---------- --------- ------- ------- -------
MATHS Book 1 15.99 14.99 13.99 15.99
MATHS Book 2 14.99 14.99 13.99 15.99
MATHS Book 3 13.99 14.99 13.99 15.99
ENGLISH Book A 10.99 10.49 9.99 10.99
ENGLISH Book B 9.99 10.49 9.99 10.99
Потянуть только МИН / МАКСсредние затраты (округлены до 2 десятичных знаков)
SELECT
ROUND(MIN(MM.AVGCOST), 2) AS MINAVG,
ROUND(MAX(MM.AVGCOST), 2) AS MAXAVG
FROM
(
SELECT BOOK_SUBJECT,
AVG(BOOK_COST) AS AVGCOST
FROM BOOK
GROUP BY BOOK_SUBJECT
) MM
Вернет
MINAVG MAXAVG
------ ------
10.49 14.99