Oracle数据字符串拼接

 select tablename,  
       ltrim(max(sys_connect_by_path(fieldname, ',')), ',') as fields
  from (select tablename,
               fieldname,  
               rnFirst,  
               lead(rnFirst) over(partition by tablename order by ordernumber asc) rnNext  
          from (select a.tablename,
                       a.fieldname,
                       a.ordernumber,
                       row_number() over(order by a.tablename, a.ordernumber asc) rnFirst  
                  from vm_employeetablefields a  where a.ismastertable=1 and  a.employeeid=119 and a.rolemoduleid=230) tmpTable1) tmpTable2  
 start with rnFirst=1
connect by rnFirst = prior rnNext  
 group by tablename;


 

你可能感兴趣的:(Oracle)