Oracle wm_concat()函数的实际运用
作用:把一个数据表中多条记录的指定数据列值,以逗号(,)间隔形式返回。
select decode(V_VALUE_TYPE,'01',wm_concat(order_code),
'02',wm_concat(to_char(order_date,'yyyy-mm-dd')),
'03',wm_concat(trim(remark))
)
into ls_return_string
from (
select order_code,factory_code,order_type,order_date,trunc(order_date,'month') order_date_month,remark
from sts_env_report_infor
where FACTORY_CODE = V_FACTORY_CODE
and
ORDER_TYPE = V_FLAG
and
trunc(ORDER_DATE,'month')= decode(ln_row,1,V_REPORT_DATE,ldt_max_date)
)
group by factory_code,order_type,order_date_month;