Questions tagged [gaps-and-islands]

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.

163 questions
6
votes
3 answers

How to group data within a time span

I have a group of rows sorted by date as below: 2017-01-01 2017-01-01 2017-01-02 2017-01-03 2017-01-04 2017-01-17 2017-01-18 2017-01-18 2017-01-18 2017-01-19 2017-01-19 2017-01-26 2017-01-27 2017-01-27 DDL & DML for those willing to help: CREATE…
user117149
  • 61
  • 1
  • 2
1
vote
1 answer

Identifying/Counting Unique Claims

I need your help to get a count of unique claims from a table where claim_id and claim_id2 can occasionally crisscross So for example, given a table with the following rows: Table scripts: create table claim_table ( id int identity(1,1), claim_id…
Gar
  • 11
  • 1
0
votes
3 answers

Find the missing numbers in a given range

Hi I have a table that has start and end columns that has the values Start End 9 10 11 19 29 44 45 51 56 60 Now if I give the range like 15 to 60 I need to return the values that not being covered in the above…
malapati
  • 1
  • 1
  • 2