用一条语句实现几乎是不可能的
写一个pl/sql块吧

解决方案 »

  1.   

    create or replace function get_user_name(p_id in varchar2) return varchar2 is
     Result varchar2(100);
     
     cursor rad_cursor(v_user_name varchar2) is
            select  user_name  from tbl_user 
            where id=v_id ;begin
    Result:='';
       for v_sor in rad_cursor(p_id) loop
           Result:=Result||','||v_sor.user_name;
        
        end loop; 
       return(Result);
    end get_user_name;
    /select id,get_user_name(id) from tbl_user group by id;
      

  2.   

    select a.x,b.x,c.x,d.x,e.x
    from
    (select x from table where ...) a,
    (select x from table where ...) b,
    (select x from table where ...) c,
    (select x from table where ...) d,
    (select x from table where ...) e
    where ...