Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- len()
- 반복문
- IN
- wcss
- analizer
- 최댓값
- count()
- del
- elbow method
- list
- matplotlib
- data
- DataAccess
- DataFrame
- sklearn
- 덴드로그램
- dendrogram
- hierarchical_clustering
- Dictionary
- numpy
- nan
- append()
- Machine Learning
- 최솟값
- function
- Python
- insert()
- string
- 분류 결과표
- pandas
Archives
- Today
- Total
개발공부
[MySQL] 조건문 CASE 본문
CASE
CASE와 WHEN 이 함께쓰이고, WHEN의 조건이 참이면 THEN에 설정한 반환 값으로 출력
WHEN의 조건이 거짓이면 ELSE 의 값으로 출력된다.
예제
books 테이블

년도가 2000년 이후에 나온 책들은 'Modern'이라고 하고,
그렇지 않은 책들은 'Old'라고하는 'Genre' 컬럼을 새로 만들어서 출력하라
select *,
case
when released_year >= 2000 then 'Modern'
else 'Old'
end as 'Genre'
from books;

'Database > MySQL' 카테고리의 다른 글
| [MySQL] NULL 값을 처리하는 함수 IFNULL() (0) | 2022.05.17 |
|---|---|
| [MySQL] 조건문 IF (0) | 2022.05.17 |
| [MySQL] 날짜 데이터 연산 datediff(), date_add(), +, - (0) | 2022.05.16 |
| [MySQL] 날짜 형식을 바꾸는 date_format() (0) | 2022.05.16 |
| [MySQL] 시간 데이터 년, 월, 일, 시, 분, 초, 요일 가져오기 (0) | 2022.05.16 |