Click here to Skip to main content
15,908,673 members
Articles / Programming Languages / SQL

How to find a gap in the table between min and max value using pure SQL

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
14 Nov 2012CPOL 0  
While Shanalal Kasims solution is cool, it doesn't work when you have a larger gap in the sequence.This is pure SQL and should work for all cases:WITH M AS ( SELECT Max(SEQUENCE) s FROM table1 WHERE id = 1 ),numbers(n) AS ( SELECT 1 AS n UNION ALL...

Views

Daily Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Database Developer
Sweden Sweden
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions