Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Islands demonstration
CREATE TABLE NumSeq (seqval int); INSERT INTO NumSeq(seqval) VALUES (2) ,(3) ,(11) ,(12) ,(13) ,(31) ,(33) ,(34) ,(35) ,(42) ; -- Inner query demonstrates how as seqval and rownum iterate by 1 each row, the difference between them remains constant at 1, creating unique 'grp's. SELECT seqval ,ROW_NUMBER() OVER(ORDER BY seqval) AS rownum ,seqval - ROW_NUMBER() OVER(ORDER BY seqval) AS grp FROM NumSeq; -- Selecting the min and max values for each group SELECT MIN(seqval) AS start_range ,MAX(seqval) AS end_range FROM( SELECT seqval ,seqval - ROW_NUMBER() OVER(ORDER BY seqval) AS grp FROM NumSeq ) AS D GROUP BY grp ORDER BY 1;
run
|
edit
|
history
|
help
0
enrj
sss
3c
1258. Find the Start and End Number of Continuous Ranges
Current time/date, timezone
JieShenLaiOfferSQL
LeetCode 262
Update as a function result
3
Movie Rating SQL Analysis Project