728x90
프로그래머스 유형별 문제 도장깨기 챌린지 !
1. 조건에 맞는 도서 리스트 출력하기
https://school.programmers.co.kr/learn/courses/30/lessons/144853
-- 조건에 부합하는 도서 리스트 출력하기
SELECT BOOK_ID
, DATE_FORMAT(PUBLISHED_DATE, '%Y-%m-%d') AS PUBLISHED_DATE
FROM BOOK
WHERE 1=1
AND PUBLISHED_DATE >= '2021-01-01'
AND PUBLISHED_DATE <= '2021-12-31'
AND CATEGORY = '인문'
ORDER BY PUBLISHED_DATE -- 오름차순으로 정렬
2. 조건에 맞는 중고거래 댓글 조회하기
https://school.programmers.co.kr/learn/courses/30/lessons/164673
SELECT t1.TITLE
, t2.BOARD_ID
, REPLY_ID
, t2.WRITER_ID
, t2.CONTENTS
, DATE_FORMAT(t2.CREATED_DATE, '%Y-%m-%d') AS CREATED_DATE
FROM USED_GOODS_BOARD t1
JOIN USED_GOODS_REPLY t2 ON t1.BOARD_ID = t2.BOARD_ID
WHERE 1=1
AND t1.CREATED_DATE LIKE '2022-10%'
ORDER BY CREATED_DATE ASC, t1.TITLE ASC
3. 조건에 맞는 중고거래 댓글 조회하기
https://school.programmers.co.kr/learn/courses/30/lessons/131120
SELECT MEMBER_ID
, MEMBER_NAME
, GENDER
, DATE_FORMAT(DATE_OF_BIRTH, '%Y-%m-%d') AS DATE_OF_BIRTH
FROM MEMBER_PROFILE
WHERE 1=1
AND DATE_OF_BIRTH LIKE '%-03-%'
AND GENDER = 'W'
AND TLNO IS NOT NULL
ORDER BY MEMBER_ID
4. 흉부외과 또는 일반외과 의사 목록 출력하기
https://school.programmers.co.kr/learn/courses/30/lessons/132203
SELECT DR_NAME
, DR_ID
, MCDP_CD
, DATE_FORMAT(HIRE_YMD, '%Y-%m-%d') AS HIRE_YMD
FROM DOCTOR
WHERE MCDP_CD = 'CS' OR MCDP_CD = 'GS'
ORDER BY HIRE_YMD DESC,
DR_NAME ASC
5. 과일로 만든 아이스크림 고르기
https://school.programmers.co.kr/learn/courses/30/lessons/133025
SELECT A.FLAVOR
FROM FIRST_HALF A JOIN ICECREAM_INFO B
ON A.FLAVOR = B.FLAVOR
WHERE A.TOTAL_ORDER > 3000 AND B.INGREDIENT_TYPE = 'fruit_based'
ORDER BY A.TOTAL_ORDER DESC
6. 평균 일일 대여 요금 구하기
https://school.programmers.co.kr/learn/courses/30/lessons/151136
SELECT ROUND(AVG(DAILY_FEE)) AS AVERAGE_FEE
FROM CAR_RENTAL_COMPANY_CAR
WHERE CAR_TYPE = 'SUV'
7. 서울에 위치한 식당 목록 출력하기
https://school.programmers.co.kr/learn/courses/30/lessons/131118
SELECT t1.REST_ID, REST_NAME, FOOD_TYPE, FAVORITES, ADDRESS, ROUND(AVG(REVIEW_SCORE), 2) AS SCORE
FROM REST_INFO t1
JOIN REST_REVIEW t2 ON t1.REST_ID = t2.REST_ID
GROUP BY t1.REST_ID
HAVING ADDRESS LIKE '서울%'
ORDER BY SCORE DESC, FAVORITES DESC
8. 재구매가 일어난 상품과 회원 리스트 구하기
https://school.programmers.co.kr/learn/courses/30/lessons/131536
SELECT USER_ID
, PRODUCT_ID
FROM ONLINE_SALE
GROUP BY USER_ID, PRODUCT_ID
HAVING COUNT(*) >= 2
ORDER BY USER_ID ASC -- 정렬
, PRODUCT_ID DESC
9. 오프라인/온라인 판매 데이터 통합하기
https://school.programmers.co.kr/learn/courses/30/lessons/131537
SELECT DATE_FORMAT(SALES_DATE, '%Y-%m-%d') AS SALES_DATE
, PRODUCT_ID
, USER_ID
, SALES_AMOUNT
FROM ONLINE_SALE t1
WHERE SALES_DATE LIKE '2022-03-%'
UNION
SELECT DATE_FORMAT(SALES_DATE, '%Y-%m-%d') AS SALES_DATE
, PRODUCT_ID
, NULL AS USER_ID
, SALES_AMOUNT
FROM OFFLINE_SALE t2
WHERE SALES_DATE LIKE '2022-03-%'
ORDER BY SALES_DATE ASC, PRODUCT_ID ASC, USER_ID ASC
-- 판매일 오름차순, 상품 ID 오름차순, 유저 ID 오름차순
728x90
'Data Engineering > SQL' 카테고리의 다른 글
[SQL] SQL 실행순서 (0) | 2024.08.21 |
---|---|
[SQL] 프로그래머스 SQL 풀이 - SUM, MAX, MIN (0) | 2024.06.19 |
[MySQL] ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 에러 해결 (0) | 2023.06.06 |
[MySQL] WHERE vs SELECET vs ORDER BY 실행순서 (Unknown column 에러가 나는 이유) (0) | 2023.04.06 |
프로그래머스 SQL - SELECT 문 (0) | 2023.04.03 |