如何使用 plsql 或 sql 将 '--' 记录与 'non--' 记录合并?

How to merge the '--' records with 'non--' records using plsql or sql?

Please see this image

ID SEQNO 日期文本

CD1 1   12/1/2015   HELLO HO    
CD1 2   12/1/2015    --W ARE YOU    
CD1 3   12/1/2015    --? received an account recovery   
CD1 4   12/1/2015    --request on   
CD1 5   12/1/2015    -- Stack   
CD1 6   12/1/2015    -- Overflow.   
CD1 7   12/2/2015   This email address is   
CD1 8   12/2/2015    ---associated with 
CD1 9   12/2/2015    --an account, but  
CD1 10  12/2/2015    ---no password is associated.  
CD1 11  12/3/2015   As a reminder, you  
CD1 12  12/3/2015    --can use any of the following credentials.    
CD1 13  12/3/2015   once logged in, you can review existing credentials.    
CD1 14  12/3/2015   If you did not initiate this account recovery reque 
CD1 15  12/3/2015    --st, just ignore this email   
Required Answer:                
ID  SEQNO   DATE    TEXT    
CD1 1   12/1/2015   HELLO HOW ARE YOU.? received an account recovery request on Whosebug.  
CD1 7   12/2/2015   This email address is associated with an account, but no password is associated.    
CD1 11  12/3/2015   As a reminder, you can use any of the following credentials.    
CD1 13  12/3/2015   once logged in, you can review existing credentials.    
CD1 14  12/3/2015   If you did not initiate this account recovery request, just ignore this email   

代码?您能帮我使用 plsql 或 sql 将 '--' 记录与 'non--' 记录合并吗?

目前还不清楚如何做到这一点。您需要确定这些组。一种方法是为每一行分配它之前的非 -- 行数。您可以使用累计和来执行此操作。这提供了聚合所需的信息:

select id, min(seqno) as seqno, min(date) as date,
       listagg((case when text like '--' then substr(text, 3)
                     else text
                end), ' ') within group (order by seqno)
from (select t.*,
             sum(case when text not like '--%' then 1 else 0 end) over
                 (order by id, seqno) as grp
      from t
     ) t
group by grp, id;