SELECT COLL_ORG_CODE, COLL_YEAR, DOC_TYPE, '1' AS SEQ, 
        SUM(DOC_TOTAL ) AS TOTAL , 
        SUM(DOC_TERM01) AS TERM01,
        SUM(DOC_TERM03) AS TERM03, 
        SUM(DOC_TERM05) AS TERM05,
        SUM(DOC_TERM10) AS TERM10,
        SUM(DOC_TERM20) AS TERM20, 
        SUM(DOC_TERM30) AS TERM30,
        SUM(DOC_TERM40) AS TERM40
  FROM SW_STATICS_03 
 GROUP BY COLL_ORG_CODE, COLL_YEAR, DOC_TYPE
 UNION ALL
SELECT COLL_ORG_CODE, COLL_YEAR, DOC_TYPE, '2' AS SEQ, 
        SUM(DET_TOTAL ) AS TOTAL , 
        SUM(DET_TERM01) AS TERM01,
        SUM(DET_TERM03) AS TERM03, 
        SUM(DET_TERM05) AS TERM05,
        SUM(DET_TERM10) AS TERM10,
        SUM(DET_TERM20) AS TERM20, 
        SUM(DET_TERM30) AS TERM30,
        SUM(DET_TERM40) AS TERM40
  FROM SW_STATICS_03 
 GROUP BY COLL_ORG_CODE, COLL_YEAR, DOC_TYPE