[프로그래머스 SQL 고득점 Kit] IS NULL: 경기도에 위치한 식품창고 목록 출력하기
문제 정답 SELECT WAREHOUSE_ID, WAREHOUSE_NAME, ADDRESS, IFNULL(FREEZER_YN, 'N') AS FREEZER_YN FROM FOOD_WAREHOUSE WHERE WAREHOUSE_NAME LIKE '%경기%' ORDER BY WAREHOUSE_ID
문제 정답 SELECT WAREHOUSE_ID, WAREHOUSE_NAME, ADDRESS, IFNULL(FREEZER_YN, 'N') AS FREEZER_YN FROM FOOD_WAREHOUSE WHERE WAREHOUSE_NAME LIKE '%경기%' ORDER BY WAREHOUSE_ID
문제 정답 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 ANIMAL_TYPE, COUNT(ANIMAL_TYPE) AS count FROM ANIMAL_INS GROUP BY ANIMAL_TYPE ORDER BY ANIMAL_TYPE
문제 정답 SELECT NAME, COUNT(NAME) AS COUNT FROM ANIMAL_INS GROUP BY NAME HAVING COUNT(NAME) >= 2 ORDER BY NAME
문제 정답 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 HOUR(DATETIME) AS HOUR, COUNT(HOUR(DATETIME)) AS COUNT FROM ANIMAL_OUTS GROUP BY HOUR HAVING HOUR BETWEEN 9 AND 19 ORDER BY HOUR
문제 정답 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..