ETC/etc3

[SQL Exercise] 6. 문자열 데이터 조작하기 CAST로 데이터 타입 변환하기

montmer27 2025. 11. 28. 12:10

New Skill unlocked!

REPLACE(), SUBSTRING(), CONCAT()으로 문자열 데이터 조작하기


사용법

1. Replace(변화 대상 문자, 대체 문자)

2. Substring(변화 대상 컬럼, 시작 지점, 가져올 길이)

3. Concat(문자1, 문자2, ...)

 

New Skill unlocked!

CAST 함수를 이용해 데이터 타입을 변환하기


1. 사용법

Cast(컬럼명 as 데이터타입)

 

2. 용례

- 숫자로 변경

cast(rating as decimal)

 

 - 문자로 변경 + 문자 합치기

concat(restaurant_name, '-', cast(order_id as char))