Write a SQL query to find the gaps, and also another one to find the number of gaps in the column.

Write a query to find the gaps. For example

gaps values
1 463000
2 45000
4 998000
6 147000
7 410000
8 346000
9 896000
10 370000
11 870000
12 123000
13 627000
16 901000
17 476000
18 12000
19 909000
21 610000

In the first column there are gaps between these pairs (4,6), (13,16), (19,21),

Write a SQL query to find the gaps.

 

PT 2:

In this example, given, gaps values
1 463000
2 45000
4 998000
6 147000
7 410000
8 346000
9 896000
10 370000
11 870000
12 123000
13 627000
16 901000
17 476000
18 12000
19 909000
21 610000

(4,6) counts as 1 gap

(13,16) counts as 1 gap

(19,21) counts as 1 gap

Between 1 and 21 there are 3 gaps.

You are being asked to write a query to find the number of gaps between 1 and 1000.

 

 

 

 

 

The post SQL query analysis first appeared on COMPLIANT PAPERS.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *