Skip to content

Querying for Contiguous Series

June 25, 2010

A deceptively simple question:

How to select the first continous group of rows using Oracle SQL (Stackoverflow)

The solution given by Malgrat works nicely. He generates a “gap” column which detects changes in the data, then uses a running total to restrict the results to the first “group”. I haven’t come up with a more elegant solution that doesn’t involve multiple table scans.

From → SQL

Comments are closed.


Get every new post delivered to your Inbox.

Join 271 other followers

%d bloggers like this: