The idea is that say you have the following table.
-------------
| oID | Area|
-------------
| 1 | 5 |
| 2 | 2 |
| 3 | 3 |
| 5 | 3 |
| 6 | 4 |
| 7 | 5 |
-------------
If grouping by continuity is possible this pseudo query
SELECT SUM(Area) FROM sample_table GROUP BY CONTINUITY(oID)
would return
-------------
| SUM(Area) |
-------------
| 10 |
| 12 |
-------------
Where the continuity break arises at oID or rather the lack thereof an entry representing oID 4.
Does such functionality exist within the standard functions of Sql?
There is no such functionality in “standard functions of SQL”, but it is possible to get the desired result set by using some tricks.
With the subquery illustrated below we create a virtual field which you can use to
GROUP BYin the outer query. The value of this virtual field is incremented each time when there is a gap in the sequence ofoID. This way we create an identifier for each of those “data islands”:Test table and data generation:
I need to thank Quassnoi for pointing out this trick in my related question 😉
UPDATE: added test table and data and fixed duplicate column name in example query.