SQL 알고리즘 코드카타

SQL 알고리즘 코드카타 32일차 26.02.12(목)

nom_de_plume 2026. 2. 12. 20:51

부제:

Triangle Judgement

 

1. 문제 링크:https://leetcode.com/problems/triangle-judgement/
2. 정답 코드: 

select
    x,
    y,
    z,
    case
        when x+y > z and x+z > y and y+z > x then 'Yes'
        else 'No'
    end as triangle
from Triangle


3. 오류 상황:

select
    x,
    y,
    z,
    case
        when x+y > z or x+z > y or y+z > x then 'Yes'
        else 'No'
    end as triangle
from Triangle

=> sql 연산자 오류


4. 시도 방법:

=> or 대신 and 사용


5. 최종 문제 해결 방법:

=> 모든 조건이 만족할때만 삼각형이기 때문에 or이 아닌 and 연산자를 사용해야한다.