大家好,如何把查询结果以一行展现出来?步骤一:新建一表create table t_temp(
       col varchar2(10)
)
步骤二:往表里插入数据insert into t_temp values('P268');
insert into t_temp values('P267');
insert into t_temp values('P266');
commit;
问题:怎么把查询结果以一行显示出来,如“P268,P267,P266”
谢谢。

解决方案 »

  1.   

    select substr(max(sys_connect_by_path(col ,',')),2) arr
    from (
    select col ,row_number() over(order by col ) rn
    from t_temp
    )
    start with rn=1
    connect by rn-1=prior rn
    ORCALE 9i
      

  2.   

    10GSELECT WMSYS.WM_CONCAT(COL) FROM T_TEMP
      

  3.   

    select a.col, b.col, c.col from
    (select col,rownum rn from t_temp) a,
    (select col,rownum rn from t_temp) b,
    (select col,rownum rn from t_temp) c
    where a.rn=1 and b.rn=2 and c.rn=3
    /