sql - Group by calculating the non-breaking periods from two (from and to) values -


which oracle sql-technique possible use concatenate rows:

id | | --------------  |   20 | 25  |   26 | 30  |   32 | 40  b |    1 |  5  b |    7 | 10  b |   11 | 20 

for such result:

 |   20 | 30  |   32 | 40  b |    1 |  5  b |    7 | 20 

? assumed from , to start , end of integer period, , necessary choose non-breaking periods id's

just looking right direction , example, can done using group by or connect by or else?

db oracle database 11g enterprise edition release 11.1.0.6.0 - 64bit production

maybe similar:

select     field_id,     min(field_from),     max(field_to) (     select         field_from,         field_to,         field_id,         sum(willsum) over(partition field_id order field_from) gid     (         select             field_from,             field_to,             field_id,             case when field_from                     = lag(field_to) over(partition field_id order field_from)                  0 else 1 end willsum + 1                     rj_mytest         )     ) group     field_id,     gid order     field_id,     min(field_from); 

there few similar example: https://forums.oracle.com/thread/969005


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -