반응형
250x250
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 |
Tags
- bootstrap
- 도커
- Kafka
- Spring
- aws
- VPN
- IntelliJ
- SQL
- AWS CI/CD 구축하기
- Python
- Spring Error
- java bigdecimal
- JavaScript
- codedeploy error
- codedeploy
- redis
- codepipeline
- chart.js
- PostgreSQL
- aws cicd
- Jenkins
- or some instances in your deployment group are experiencing problems.
- chartjs
- COALESCE
- codebuild
- Airflow
- node
- docker
- Flux
- kubeflow
Archives
- Today
- Total
Small Asteroid Blog
[SQL] COALESCE , LEAD, LAG 함수 (NULL이 아닌 첫번째 값, 이전값, 다음값) 본문
728x90
LAG : 절 기준으로 이전의 로우의 값 변환
LAG(조건, 순서, 디폴트) OVER ( PARTITION BY 절)
LEAD : 절 기준으로 이후의 로우의 값 변환
LEAD(조건, 순서, 디폴트) OVER ( PARTITION BY 절)
COALESCE 함수 : 해당 칼럼들 중 NULL이 아닌 첫번째 값을 반환하는 함수 (오라클 NVL과 비슷한 기능)
COALESCE(a_1, a_2, ..., a_N)
a_1 부터 a_N까지 순서대로 비교 후 null 이 아닌 값을 반환한다. 모두 null이면 null을 리턴한다.
grade 에 값이 null일 경우 #으로 치환한다.
select coalesce(grade,'#')
from student
728x90
반응형
'백엔드 > DB' 카테고리의 다른 글
[mysql] cannot check if timestamp is between varchar(23) and varchar(23) - 날짜 조회 쿼리 (0) | 2021.09.28 |
---|---|
select limit ? offset ? (페이징 활용) (0) | 2021.09.23 |
[sql] case - when - then - else - end (0) | 2021.07.30 |
[DB] Star Schema / Snowflake schema / Fact Table / Dimension Table (0) | 2021.07.22 |
[SQL] UNION과 UNION ALL의 차이 (0) | 2021.07.22 |