문제 정답 SELECT CATEGORY, PRICE AS MAX_PRICE, PRODUCT_NAME FROM FOOD_PRODUCT WHERE PRICE IN (SELECT MAX(PRICE) FROM FOOD_PRODUCT GROUP BY CATEGORY) AND CATEGORY IN ('과자', '국', '김치', '식용유') ORDER BY MAX_PRICE DESC
문제 정답 SELECT A.AUTHOR_ID, AUTHOR_NAME, CATEGORY, SUM(PRICE * SALES) AS TOTAL_SALES FROM BOOK AS A JOIN AUTHOR AS B ON A.AUTHOR_ID = B.AUTHOR_ID JOIN BOOK_SALES AS C ON A.BOOK_ID = C.BOOK_ID WHERE C.SALES_DATE LIKE '2022-01%' GROUP BY A.AUTHOR_ID, CATEGORY ORDER BY A.AUTHOR_ID ASC, CATEGORY DESC
문제 정답 SELECT INGREDIENT_TYPE, SUM(TOTAL_ORDER) AS TOTAL_ORDER FROM FIRST_HALF AS A JOIN ICECREAM_INFO AS B ON A.FLAVOR = B.FLAVOR GROUP BY INGREDIENT_TYPE ORDER BY TOTAL_ORDER2021
문제 정답 SELECT YEAR(SALES_DATE) AS YEAR, MONTH(SALES_DATE) AS MONTH, GENDER, COUNT(DISTINCT A.USER_ID) AS USERS FROM USER_INFO AS A JOIN ONLINE_SALE AS B ON A.USER_ID = B.USER_ID WHERE GENDER IS NOT NULL GROUP BY YEAR, MONTH, GENDER ORDER BY YEAR, MONTH, GENDER
문제 정답 SET @HOUR = -1; # 어떤 변수에 특정 값을 할당할 때 사용 SELECT (@HOUR := @HOUR + 1) AS HOUR, (SELECT COUNT(HOUR(DATETIME)) FROM ANIMAL_OUTS WHERE HOUR(DATETIME) = @HOUR) AS COUNT # HOUR(DATETIME)과 @HOUR가 동일해지는 순간 카운트 FROM ANIMAL_OUTS WHERE @HOUR < 23
문제 정답 SELECT CASE WHEN PRICE IN ( SELECT PRICE FROM PRODUCT WHERE PRICE >= 0 AND PRICE = 10000 AND PRICE = 20000 AND PRICE = 30000 AND PRICE < 40000 ) THEN 30000 WHEN PRICE I..
문제 정답 SELECT B.USER_ID, B.NICKNAME, SUM(PRICE) AS TOTAL_SALES FROM USED_GOODS_BOARD AS A JOIN USED_GOODS_USER AS B ON A.WRITER_ID = B.USER_ID WHERE STATUS = 'DONE' GROUP BY A.WRITER_ID HAVING TOTAL_SALES >= 700000 ORDER BY TOTAL_SALES