Photo of Sample Data in blue I have data in this format. I need to find missing for each set of non missing value. Or if I can create a columns that counts groups of non missing elements in SQL server.
MOB ID Column1 Column2
0 123 Null Null
1 123 Null Null
2 123 25 25
3 123 36 25
4 123 Null Null
5 123 Null Null
6 123 Null Null
7 123 15 15
8 123 23 15
9 123 24 15
10 123 41 15
11 123 Null Null
12 123 Null Null
13 123 Null Null
14 123 Null Null
15 123 Null Null
16 123 Null Null
17 123 Null Null
18 123 77 77
19 123 Null Null
20 123 Null Null
21 123 Null Null
22 123 22 22
23 123 35 22
24 123 38 22
In the example above, the first three columns represent the columns in my table. The fourth column (Column2
) is an artificial column I want to generate in a SELECT statement, based on getting the minimum value of Column1
from each "island" of NON-NULL values in Column1
.