日期:2014-05-17 浏览次数:20900 次
set serveroutput on
declare
cursor c1 is select distinct code from t1 order by code;
v_sql varchar2(1024);
begin
v_sql := 'select '
------解决方案--------------------
chr(10)
------解决方案--------------------
'no,'
------解决方案--------------------
chr(10);
for c1_result in c1 loop
v_sql := v_sql
------解决方案--------------------
'sum(case code when '''
------解决方案--------------------
c1_result.code
------解决方案--------------------
''' then cost else 0 end) c'
------解决方案--------------------
c1_result.code
------解决方案--------------------
','
------解决方案--------------------
chr(10);
end loop;
v_sql := substr(v_sql, 0, length(v_sql) - 2);