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 고득점 Kit] SELECT #33

Open
sieunnnn opened this issue Nov 23, 2023 · 5 comments
Open

[프로그래머스/SQL 고득점 Kit] SELECT #33

sieunnnn opened this issue Nov 23, 2023 · 5 comments
Assignees
Labels
SQL SQL 문제풀이 프로그래머스 프로그래머스 문제풀이

Comments

@sieunnnn
Copy link
Owner

sieunnnn commented Nov 23, 2023

프로그래머스 SQL 고득점 Kit SELECT 문제풀이 입니다.

@sieunnnn sieunnnn self-assigned this Nov 23, 2023
@sieunnnn sieunnnn added 프로그래머스 프로그래머스 문제풀이 SQL SQL 문제풀이 labels Nov 23, 2023
@sieunnnn
Copy link
Owner Author

3월에 태어난 여성 회원 목록 출력하기

포맷 조심

DATE_FORMAT(DATE_OF_BIRTH, '%Y-%m-%d') AS DATE_OF_BIRTH

조건 조심

3월에 태어난 여성이므로 아래와 같이 MONTH 함수를 이용하여 해당 달을 찾습니다.

MONTH(DATE_OF_BIRTH) = 3

@sieunnnn
Copy link
Owner Author

12세 이하인 여자 환자 목록 출력하기

값이 NULL 일 경우, 출력 형식 변경하려면

IFNULL(TLNO, 'NONE')

@sieunnnn
Copy link
Owner Author

상위 n개 레코드

만약 정렬 후 특정 개수만 뽑고 싶다면 아래와 같이 사용하면 됩니다.

SELECT NAME
FROM ANIMAL_INS
ORDER BY DATETIME
LIMIT 1;

@sieunnnn
Copy link
Owner Author

SQL JOIN

image

@sieunnnn
Copy link
Owner Author

sieunnnn commented Dec 7, 2023

오프라인/온라인 판매 데이터 통합하기

UNION

  • 같은 성격의 값을 한번의 쿼리로 추출할 수 있도록 도와주는 연산자 입니다.
  • 필드명과 타입이 같아야 합니다.

NULL

해당 문제의 경우 오프라인 테이블에는 USER_ID 칼럼이 존재하지 않았습니다. 하지만 위에서 말한대로 UNION 연산자를 사용하기 위해서는 필드명과 타입을 맞춰줘야 합니다. 따라서 NULL AS USER_ID 로 별칭을 붙여 주었습니다.

@sieunnnn sieunnnn reopened this Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SQL SQL 문제풀이 프로그래머스 프로그래머스 문제풀이
Projects
None yet
Development

No branches or pull requests

1 participant