Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
Q4
PostgresInsertIfNotExists
Yy
conditionally add “another row” in SQL Server?
PostreSQL: Subquery
Transform sequential key value data to row based key value data
Ass2 q2
nested array to table
3
G.Giftcard Interview Analysis Conducted by Miranda Zhao
Please log in to post a comment.