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.

About these ads

From → SQL

Comments are closed.

Follow

Get every new post delivered to your Inbox.

Join 205 other followers

%d bloggers like this: