原数据: 目标结果: 根据-符号将数据进行分组,思路是根据NAME列值进行复制,若为‘-’则赋值1,其他为0,这样就可以根据累加实现分组, 具体实现代码: /* Formatted on 2019/9/24 9:53:25 (QP5 v5.227.12220.39754) */SELECT * FROM (SELECT ID, NAME, SUM (SIGN) OVER (ORDER BY ID) AS VA FROM (SELECT ID, NAME, DECODE (TRIM (NAME),