Top "Gaps-and-islands" questions

Gaps and islands problems involve finding a range of missing values (gaps) or a range of consecutive values (islands) in a sequence of numbers or dates.

Trouble using ROW_NUMBER() OVER (PARTITION BY ...)

I'm using SQL Server 2008 R2. I have table called EmployeeHistory with the following structure and sample data: EmployeeID Date DepartmentID …

sql sql-server sql-server-2008 row-number gaps-and-islands
Get a list of dates between two dates

Using standard mysql functions is there a way to write a query that will return a list of days between …

mysql sql date gaps-and-islands
SQL query to find Missing sequence numbers

I have a column named sequence. The data in this column looks like 1, 2, 3, 4, 5, 7, 9, 10, 15. I need to find the missing sequence …

sql-server-2005 gaps-and-islands
How to check any missing number from a series of numbers?

I am doing a project creating an admission system for a college; the technologies are Java and Oracle. In one …

sql oracle plsql gaps-and-islands
How to find gaps in sequential numbering in mysql?

We have a database with a table whose values were imported from another system. There is an auto-increment column, and …

mysql sql gaps-and-islands
How do I find a "gap" in running counter with SQL?

I'd like to find the first "gap" in a counter column in an SQL table. For example, if there are …

sql gaps-and-islands
MySQL how to fill missing dates in range?

I have a table with 2 columns, date and score. It has at most 30 entries, for each of the last 30 days …

mysql sql recursive-query gaps-and-islands date-arithmetic
Find the smallest unused number in SQL Server

How do you find the smallest unused number in a SQL Server column? I am about to import a large …

sql sql-server gaps-and-islands
Detect consecutive dates ranges using SQL

I want to fill the calendar object which requires start and end date information. I have one column which contains …

sql sql-server sql-server-2008 gaps-and-islands
MySQL: Select All Dates In a Range Even If No Records Present

I have a database of users. I would like to create a graph based on userbase growth. The query I …

mysql date gaps-and-islands