반응형
경기도에 위치한 식품창고 목록 출력하기(Lv.1)
https://school.programmers.co.kr/learn/courses/30/lessons/131114?language=mysql
# MySQL
# IFNULL
SELECT WAREHOUSE_ID, WAREHOUSE_NAME, ADDRESS, IFNULL(FREEZER_YN, 'N') AS FREEZER_YN
FROM FOOD_WAREHOUSE
WHERE ADDRESS LIKE '경기도%'
ORDER BY WAREHOUSE_ID
# COALESCE
SELECT WAREHOUSE_ID, WAREHOUSE_NAME, ADDRESS, COALESCE(FREEZER_YN, "N") AS FREEZER_YN
FROM FOOD_WAREHOUSE
WHERE ADDRESS LIKE '경기도%'
ORDER BY WAREHOUSE_ID
# CASE-ELSE
SELECT WAREHOUSE_ID, WAREHOUSE_NAME, ADDRESS,
CASE WHEN FREEZER_YN IS NULL THEN 'N'
ELSE FREEZER_YN END AS FREEZER_YN
FROM FOOD_WAREHOUSE
WHERE ADDRESS LIKE '경기도%'
ORDER BY WAREHOUSE_ID
# ORACLE
SELECT WAREHOUSE_ID, WAREHOUSE_NAME, ADDRESS, NVL(FREEZER_YN, 'N') AS FREEZER_YN
FROM FOOD_WAREHOUSE
WHERE ADDRESS LIKE '경기도%'
ORDER BY WAREHOUSE_ID
이름이 없는 동물의 ID(Lv.1)
https://school.programmers.co.kr/learn/courses/30/lessons/59039
# MySQL, ORACLE
SELECT ANIMAL_ID
FROM ANIMAL_INS
WHERE NAME IS NULL
ORDER BY ANIMAL_ID
이름이 있는 동물의 ID(Lv.1)
https://school.programmers.co.kr/learn/courses/30/lessons/59407
# MySQL, ORACLE
SELECT ANIMAL_ID
FROM ANIMAL_INS
WHERE NAME IS NOT NULL
ORDER BY ANIMAL_ID
NULL 처리하기 (Lv.2)
https://school.programmers.co.kr/learn/courses/30/lessons/59410
# MySQL
SELECT ANIMAL_TYPE, IFNULL(NAME, 'No name'), SEX_UPON_INTAKE
FROM ANIMAL_INS
ORDER BY ANIMAL_ID
# ORACLE
SELECT ANIMAL_TYPE, NVL(NAME, 'No name') as NAME, SEX_UPON_INTAKE
FROM ANIMAL_INS
ORDER BY ANIMAL_ID
나이 정보가 없는 회원 수 구하기 (Lv.2)
https://school.programmers.co.kr/learn/courses/30/lessons/131528
# MySQL, ORACLE
SELECT count(*) AS USERS
FROM USER_INFO
WHERE AGE IS NULL
728x90
반응형
'Data > SQL' 카테고리의 다른 글
[프로그래머스] SELECT (MySQL) (0) | 2023.01.24 |
---|---|
[프로그래머스] String, Date (MySQL) (0) | 2023.01.24 |
[프로그래머스] GROUP BY (MySQL) (0) | 2023.01.22 |
[프로그래머스] JOIN (MySQL) (0) | 2023.01.22 |
[프로그래머스] SUM, MAX, MIN (MySQL, Oracle) (0) | 2023.01.21 |