MySQL Forums
Forum List  »  General

Continuous NULL value in a column
Posted by: Neil Huang
Date: March 30, 2017 08:42PM

Hello all,

I have data show as following.And the result I want also show below.

Here's what I want to do:
I want to know is there exist a continuous null in Value column
If exist and if the number larger than 2 then count the null value

e.g.:
In sequence 3 and 4, their value are Null (continuous), but only 2, so not eligible
In sequence 6, 7 and 8, their value are Null (continuous), and this is 3(larger than 2), so eligible
In sequence 10, 11, 12 and 13, their value are Null (continuous), and this is 4(larger than 2), so eligible
So the final result: 3+4=7

EQUIPMENT
+-----------+------------+-----------+
| ID | Sequence | Value |
+-----------+------------------+-----+
| 0001 | 1 | 76 |
+-----------+------------------+-----+
| 0001 | 2 | 90 |
+-----------+------------------+-----+
| 0001 | 3 | NULL |
+-----------+------------------+-----+
| 0001 | 4 | NULL |
+-----------+------------------+-----+
| 0001 | 5 | 12 |
+-----------+------------------+-----+
| 0001 | 6 | NULL |
+-----------+------------------+-----+
| 0001 | 7 | NULL |
+-----------+------------------+-----+
| 0001 | 8 | NULL |
+-----------+------------------+-----+
| 0001 | 9 | 45 |
+-----------+------------------+-----+
| 0001 | 10 | NULL |
+-----------+------------------+-----+
| 0001 | 11 | NULL |
+-----------+------------------+-----+
| 0001 | 12 | NULL |
+-----------+------------------+-----+
| 0001 | 13 | NULL |
+-----------+------------+-----------+


Result:
+-----------+----------------------+
| ID | Total_eligible_NULL |
+-----------+----------------------+
| 0001 | 7 |
+-----------+----------------------+

Is it possible to achieve that?

Options: ReplyQuote


Subject
Written By
Posted
Continuous NULL value in a column
March 30, 2017 08:42PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.