[Programmers_SQL] 9. 조건에 맞는 도서리스트 출력하기

문정준's avatar
Feb 28, 2025
[Programmers_SQL] 9. 조건에 맞는 도서리스트 출력하기
💡
프로그래머스 SELECT 9. 조건에 맞는 도서리스트 출력하기

1. 문제 설명

notion image
 

2. 문제

notion image

3. 예시

notion image
 

주의 사항

notion image

4. 문제 풀이

SELECT book_id, date_format(published_date, '%Y-%m-%d') published_date from BOOK where year(published_date) = 2021 and category = '인문' order by published_date;
  • 1 Line : 도서 ID, 출판일을 출력
    • 출판일의 형식이 ‘0000-00-00’ : date_format
    • SELECT book_id, date_format(published_date, ‘%Y-%m-%d’) published_date
  • 2 Line : BOOK 테이블에서 출력
    • FROM BOOK
  • 3 Line : 출판년도가 2021년이고, 카테고리가 인문인 데이터만을 출력
    • where year(published_year) = 2021 and category = ‘인문’
  • 4 Line : 출판일을 기준으로 오름차순 정렬
    • order by published_date;

5. 결과 확인

notion image
notion image
 
Share article

sxias