表1里有多条记录.select 字段1 from 表1结果是 字段1
001
002
003
004
...怎样写一个查询语句,能得到 "001,002,003,004,..." 这样一个字符串?只能用sql 语句实现.程序里循环的不算哈.

解决方案 »

  1.   

    干吗要用sql?pl/sql就能帮到你。
      

  2.   

    select substr(max(sys_connect_by_path(字段1,',')),2) result from
    (select 字段1,row_number()over(order by 字段1) xh from 表1)
    start with xh=1 connect by prior xh=xh-1用sys_connect_by_path就可以搞定,哈哈
      

  3.   

    要oracle 9i开始才有,9i以下怎么办?
      

  4.   

    select substr(max(sys_connect_by_path(id, ',')), 2) 
      from (select t.id, t.id - 1 rk from 表1 t)
     start with rk = 0
    connect by rk = prior id