select col coalesce(A,B) from table
- A 컬럼 값이 NULL 값이 아닌 경우 A 값을 리턴
- A가 NULL이고 B가 NULL이 아닌 경우 B 값을 리턴
- 모든 인수가 NULL이면 NULL을 반환
ex) coalesce(FREEZER_YN,'N') → FREEZER_YN이 null값이면 N 출력
→ 안에 또 다른 Where 사용 가능!
Q: Query the Western Longitude (LONG_W) for the largest Northern Latitude (LAT_N) in STATION that is less than 137.2345. Round your answer to 4 decimal places.
A: SELECT ROUND(MAX(LONG_W), 4)
FROM STATION
WHERE LAT_N = (select max(lat_n) from station where lat_n<137.2345)
select ifnull(col, '반환할 값') from table
Date_format(HIRE_YMD, '%Y-%m-%d') → HIRE_YMD를 년-월-일 순으로 바꿔서 보여줌
* 2022년이라고 가정할 때 %Y → 2022 , %y → 22 로 출력됨
5월이라고 가정할 때 %m → 05
1. where "Python" IN (SKILL1,SKILL2,SKILL3)
2. where 1=1
and (skill_1 like '%python%'
or skill_2 like '%python%'
or skill_3 like '%python%')