Skip to content
Advertisement

SQL (Redshift) – Find consecutive numbers

Suppose I have a table below:

I want to find which number(s) appears 3 times in a row. So in this example the output is 1.

How can I achieve this using regular SQL (not PL/SQL), when I have way much more rows in the data?

Thanks!

Advertisement

Answer

This should work. here is the sqlfiddle

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement