Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sql] 3월에 태어난 여성 회원 목록 출력하기 #216

Closed
hwangJi-dev opened this issue Apr 27, 2023 · 0 comments
Closed

[Sql] 3월에 태어난 여성 회원 목록 출력하기 #216

hwangJi-dev opened this issue Apr 27, 2023 · 0 comments

Comments

@hwangJi-dev
Copy link
Owner

hwangJi-dev commented Apr 27, 2023

💬 문제

https://school.programmers.co.kr/learn/courses/30/lessons/131120


💬 Idea

  • 전화번호가 NULL인 경우는 출력대상에서 제외 → IS NOT NULL 활용

  • 회원ID를 기준으로 오름차순 정렬 → ORDER BY 활용

    • 내림차순 정렬이었다면 → ORDER BY DESC
  • 데이터에 특정 값이 포함되어있는지 확인 → LIKE %aa% 활용

  • DATE_OF_BIRTH의 데이트 포맷이 예시와 동일해야 정답처리이므로 DATE의 형식을 다시 바꿔주었다.

    → DATE_FORMAT(DATE_OF_BIRTH, "%Y-%m-%d")


💬 풀이

SELECT MEMBER_ID, MEMBER_NAME, GENDER, DATE_FORMAT(DATE_OF_BIRTH, "%Y-%m-%d") AS DATE_OF_BIRTH
FROM MEMBER_PROFILE
WHERE GENDER = "W" AND DATE_OF_BIRTH LIKE '%-03-%' AND TLNO IS NOT NULL
ORDER BY MEMBER_ID

💬 알게된 문법

✅ DATE_FORMAT(날짜 , 형식)

  • 날짜를 지정한 형식으로 출력

스크린샷 2023-04-28 01 21 35

✅ LIKE

  • 컬럼명 LIKE %aa% → aa가 포함
  • LIKE %aa → aa로 시작
  • LIKE aa% → aa로 끝
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant