티스토리 뷰
https://leetcode.com/problems/consecutive-numbers
Consecutive Numbers - LeetCode
Can you solve this real interview question? Consecutive Numbers - Table: Logs +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | num | varchar | +-------------+---------+ In SQL, id is the primary key for this table.
leetcode.com
with base as (
select
num
, lag(num, 1) over (order by id) rn1
, lag(num, 2) over (order by id) rn2
from logs
)
select
distinct num as 'ConsecutiveNums'
from base
where num = rn1 and rn1 = rn2
'프로그래밍연습 > SQL' 카테고리의 다른 글
[SQL]trips-and-users (0) | 2023.08.18 |
---|---|
[SQL]employees-earning-more-than-their-managers (0) | 2023.08.17 |
[SQL]SecondHighestSalary_leatcode (0) | 2023.08.17 |
[SQL]오프라인/온라인 판매 데이터 통합하기 (0) | 2023.08.16 |
[SQL]가격대 별 상품 개수 구하기 (0) | 2023.08.15 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 평균
- 코딩테스트
- Lambda
- 확률
- 뇌하수체선종
- SQL
- 뇌하수체
- 확률분포
- 파이썬
- Python
- 상관관계
- 분산
- 힙
- 군고구마
- programmers
- leatcode
- counter
- 쿠싱증후군
- 상대도수
- TensorFlow
- 분당서울대병원
- 조건부확률
- 중앙값
- neural network
- hash
- 프로그래머스
- 통계
- 사분위수
- 쿠싱
- random forest
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함