PROGRAMMERS/SQL
-
[프로그래머스] [MySQL] [Level 4] [GROUP BY] 년, 월, 성별 별 상품 구매 회원 수 구하기PROGRAMMERS/SQL 2022. 10. 23. 23:49
문제 설명 예시 -- 코드를 입력하세요 SELECT YEAR(A.SALES_DATE) AS YEAR, MONTH(A.SALES_DATE) AS MONTH, B.GENDER, COUNT(DISTINCT B.USER_ID) AS USERS FROM ONLINE_SALE A JOIN USER_INFO B ON A.USER_ID = B.USER_ID WHERE GENDER IS NOT NULL GROUP BY YEAR, MONTH, B.GENDER ORDER BY YEAR, MONTH, B.GENDER
-
[프로그래머스] [MySQL] [Level 2] [JOIN] 상품 별 오프라인 매출 구하기PROGRAMMERS/SQL 2022. 10. 14. 01:57
SELECT P.PRODUCT_CODE, (PRICE * AMOUNT) AS SALES FROM PRODUCT P JOIN ( SELECT PRODUCT_ID, SUM(SALES_AMOUNT) AS AMOUNT FROM OFFLINE_SALE GROUP BY PRODUCT_ID ) S ON P.PRODUCT_ID = S.PRODUCT_ID ORDER BY SALES DESC, PRODUCT_CODE;
-
[프로그래머스] [MySQL] [Level 4] [SELECT] 서울에 위치한 식당 목록 출력하기PROGRAMMERS/SQL 2022. 10. 14. 01:37
SELECT A.REST_ID, A.REST_NAME, A.FOOD_TYPE, A.FAVORITES, A.ADDRESS, ROUND(AVG(REVIEW_SCORE),2) AS SCORE FROM REST_INFO AS A LEFT JOIN REST_REVIEW AS B ON A.REST_ID = B.REST_ID WHERE A.ADDRESS LIKE '서울%' AND REVIEW_SCORE IS NOT NULL GROUP BY A.REST_ID ORDER BY SCORE DESC, A.FAVORITES DESC;
-
[프로그래머스] [MySQL] [Level 4] [JOIN] 5월 식품들의 총매출 조회하기PROGRAMMERS/SQL 2022. 10. 14. 00:57
-- 코드를 입력하세요 SELECT A.PRODUCT_ID, A.PRODUCT_NAME , SUM(A.PRICE * B.AMOUNT) AS TOTAL_SALES FROM FOOD_PRODUCT AS A LEFT JOIN FOOD_ORDER AS B ON A.PRODUCT_ID = B.PRODUCT_ID WHERE YEAR(B.PRODUCE_DATE) = 2022 AND MONTH(B.PRODUCE_DATE) = 5 GROUP BY PRODUCT_NAME ORDER BY TOTAL_SALES DESC, A.PRODUCT_ID