2021.03.04

Jinmin Kim·2021년 3월 4일
0

coalesce

coalesce는 null값을 대신하여서 다른값을 넣어주는 방법
아래의 코드에서는 null값이 나온다면 0으로 대체한다.

coalesce(sum((
    case severity
        when 'P1' then 64
        when 'P2' then 32
        when 'P3' then 16
        when 'P4' then 8
        when 'P5' then 4
        else 1
    end)), 0)

날짜 조건줄때에 ex)

google에 다른 ex)도 많다

to_char((now() - interval '1 day'), 'YYYY/MM/DD HH24:MI:SS')

<>

<>는 !=의 의미로 많은 sql에서 사용된다

where ins.category = 'B' and ins.comp_name <> 'A'

concat

문자열이나 변수같은 부분을 합쳐서 사용할때 concat을 사용

ins.page_id like concat('%', page_id , '%')

case when then else end

case 컬럼 when 조건 then 바꿀부분 else 이외의부분 end

case when ins is null then '없음' else ins.temp end
profile
Let's do it developer

0개의 댓글