Since some IDs have been removed from Logs. Write an SQL query to find the start and end number of continuous ranges in table Logs.
Order the result table by start_id.
The query result format is in the following example:
select min(log_id) as start_id
,max(log_id) as end_id
from (
select log_id
,row_number()over(order by log_id) as log_no
from logs
) a1
group by log_id-log_no
;
'언어 꿀Tip > SQL' 카테고리의 다른 글
10_05. Difference between timestamp (날짜,시간 차이 구하기) (0) | 2021.07.01 |
---|---|
10_03. 연속적인 숫자 생성 Recursive CTE 사용 (0) | 2021.06.30 |
10_02. [mysql] moving average & rolling sum (0) | 2021.06.30 |
10_01. PERCENT_RANK() 와 CUME_DIST() 함수 (0) | 2021.06.18 |