AGGREGATE FUNCTION (집계함수)를 조건에 추가해 조회하기 위한 SQL 문법입니다.
SELECT column1, column2,...
FROM tablename
WHERE conditon
GROUP BY column1, column2,...
HAVING condtion # AGGREGATE FUNCTION (집계함수)
ORDER BY column1, column2,...;
가정)
NAME과 PRICE를 TYPE에 따라 확인하라.
(단, PRICE가 평균 PRICE보다 높은 DATA만 확인하라.)
SELECT TYPE, NAME, PRICE
FROM testTABLE
GROUP BY TYPE
HAVING PRICE > AVG(PRICE)
ORDER BY PRICE;