2025.02.24 - [프로그래밍/SQL, Hive, SAS 관련 정보] - [SQL] Table of Contents
https://leetcode.com/problems/consecutive-numbers/?envType=study-plan-v2&envId=top-sql-50
window함수의 partition by와 order by는 필수로 넣어야 하는 옵션은 아닙니다. 가끔은 둘 다 필요 없을 때가 있죠. 이럴 때는 over() 만 해주면 됩니다.
select distinct(num) ConsecutiveNums
from
(select id, num, lag(num, 1) over() l1, lag(num, 2) over() l2
from Logs) tt
where num=l1 and num=l2;
'프로그래밍 > SQL, Hive, SAS 관련 정보' 카테고리의 다른 글
[SQL - Frequently Used Code] Min/Max 집계 함수의 활용 (0) | 2025.04.08 |
---|---|
[SQL 기초] order 기준 열의 Null (0) | 2025.04.08 |
[SQL문제풀이 - Having 절 조건주기] - Customers Who Bought All Products (0) | 2025.04.07 |
[SQL 기초] Join의 on 조건과 where 조건 (0) | 2025.04.05 |
[SQL 기초] 날짜 덧셈/뺄셈 (0) | 2025.03.23 |