Leetcode - 613. Shortest Distance in a Line
문제
정답
LAG
를 써서 1줄 차이를 구한 다음 거리를 계산했다.
SELECT MIN(dist) AS shortest
FROM (
SELECT ABS(x - LAG(x, 1) OVER (ORDER BY x)) as dist
FROM Point
ORDER BY dist
) AS Temp
WHERE dist IS NOT null
LAG
를 써서 1줄 차이를 구한 다음 거리를 계산했다.
SELECT MIN(dist) AS shortest
FROM (
SELECT ABS(x - LAG(x, 1) OVER (ORDER BY x)) as dist
FROM Point
ORDER BY dist
) AS Temp
WHERE dist IS NOT null