-------  ---------
cust_no   place_gb200604862   10
200604862   20
200604862   30select cust_no,max(sys_connect_by_path(place_gb,'|')) result from 
       (select cust_no,place_gb,rn,lead(rn) over(partition by cust_no order by rn) rn1 
       from (select cust_no,place_gb,row_number() over(order by cust_no,place_gb desc) rn from TCUSTPLACE))
       start with cust_no='200604000862' and rn1 is null connect by rn1 = prior rn group by cust_no结果:
-------  ---------
cust_no   place_gb
200604862  10|20|30可只能让一个字段合并进去,另外一个字段不重复。我现在有多个字段:  播放时间   节目名称   商品名称
-----------------------------------------
 10:25 ~ 10:30  科技享乐组   迪士尼梦幻两件套内衣 
 
 14:10 ~ 16:10   厨房好幸福3  test乐扣乐扣398畅销套装 
 
 14:10 ~ 16:10   厨房好幸福3   拳王滋味炙烤炉
 
 14:10 ~ 16:10   厨房好幸福3   test-Westinghouse西屋多功能食品加工器
 
 21:35 ~ 22:30   美丽俏佳人   韩国欣姿雅胶原蛋白套组
 
 22:30 ~ 00:00   璀璨风华      韩国欣姿雅胶原蛋白套组 
 
如果在列中,遇到重复的,就合并进去,没有重复的就不合并。“播放时间”为主索引字段。不出现重复的,这个问题难了我两天了。不知道该怎么将上面的那句整合到下面这种复合型的字段合并。
示例:http://www.ocj.com.cn/tvshop/tvshop_scheday.jsp?viewType=by_name&tabType=100021
该怎么实现啊?是不是sql语句无能为力了?

解决方案 »

  1.   

    不是太明白
    cust_no place_gb place_gc 三个字段select cust_no,max(sys_connect_by_path(place_gb,'|')) result from
    (select cust_no,place_gb,rn,lead(rn) over(partition by cust_no order by rn) rn1
    from (select cust_no,place_gb,row_number() over(order by cust_no,place_gb desc) rn from (select cust_no, place_gb || place_gc as place_gb from TCUSTPLACE)))
    start with cust_no='200604000862' and rn1 is null connect by rn1 = prior rn group by cust_no
      

  2.   

    实现的功能就是让相同内容的数据合并进去,以时间字段为主键。其他的只要有相同的,就整合进去。原:
     10:25 ~ 10:30  科技享乐组   迪士尼梦幻两件套内衣 
     
     14:10 ~ 16:10   厨房好幸福3  test乐扣乐扣398畅销套装 
     
     14:10 ~ 16:10   厨房好幸福3   拳王滋味炙烤炉变成:
     10:25 ~ 10:30  科技享乐组   迪士尼梦幻两件套内衣 
     
     14:10 ~ 16:10   厨房好幸福3  test乐扣乐扣398畅销套装 
                     厨房好幸福3   拳王滋味炙烤炉
      

  3.   

    應該是一樣的吧,試試:
    select 播放时间,max(sys_connect_by_path(节目名称,'|')) 节目名称,max(sys_connect_by_path(商品名称,'|')) 商品名称 from 
           (select 播放时间,节目名称,商品名称,rn,lead(rn) over(partition by 播放时间 order by rn) rn1 
           from (select 播放时间,节目名称,商品名称,row_number() over(order by 播放时间,节目名称,商品名称 desc) rn from TCUSTPLACE))
           start with 播放时间='14:10 ~ 16:10' and rn1 is null connect by rn1 = prior rn group by 播放时间