SELECT NR_AKT, ROK, MC, '      ' as TYP_GODZ,
PRZEP_1 AS D_1, PRZEP_2 AS D_2, PRZEP_3 AS D_3, PRZEP_4 AS D_4, PRZEP_5 AS D_5, PRZEP_6 AS D_6, PRZEP_7 AS D_7,
PRZEP_8 AS D_8, PRZEP_9 AS D_9, PRZEP_10 AS D_10, PRZEP_11 AS D_11, PRZEP_12 AS D_12, PRZEP_13 AS D_13,
PRZEP_14 AS D_14, PRZEP_15 AS D_15, PRZEP_16 AS D_16, PRZEP_17 AS D_17, PRZEP_18 AS D_18, PRZEP_19 AS D_19,
PRZEP_20 AS D_20, PRZEP_21 AS D_21, PRZEP_22 AS D_22, PRZEP_23 AS D_23, PRZEP_24 AS D_24, PRZEP_25 AS D_25, PRZEP_26 AS D_26, PRZEP_27 AS D_27, PRZEP_28 AS D_28, PRZEP_29 AS D_29, PRZEP_30 AS D_30, PRZEP_31 AS D_31,
PRZEP_SUM as D_32, 0 AS D_33
FROM VKIP_EWPRAC
WHERE ROK*100+MC>= :ROKEW_OD AND ROK*100+MC<=:ROKEW_DO AND NR_AKT=:NR_AKTEW
UNION ALL
SELECT NR_AKT, ROK, MC, 'NADL 50' as TYP_GODZ,
NADL_1 AS D_1, NADL_2 AS D_2, NADL_3 AS D_3, NADL_4 AS D_4, NADL_5 AS D_5, NADL_6 AS D_6, NADL_7 AS D_7,
NADL_8 AS D_8, NADL_9 AS D_9, NADL_10 AS D_10, NADL_11 AS D_11, NADL_12 AS D_12, NADL_13 AS D_13,
NADL_14 AS D_14, NADL_15 AS D_15, NADL_16 AS D_16, NADL_17 AS D_17, NADL_18 AS D_18, NADL_19 AS D_19,
NADL_20 AS D_20, NADL_21 AS D_21, NADL_22 AS D_22, NADL_23 AS D_23, NADL_24 AS D_24, NADL_25 AS D_25, NADL_26 AS D_26, NADL_27 AS D_27, NADL_28 AS D_28, NADL_29 AS D_29, NADL_30 AS D_30, NADL_31 AS D_31,
NADL_SUM50 AS D_32, 0 AS D_33
FROM VKIP_EWPRAC
WHERE NADL_SUM50<>0 AND ROK*100+MC>= :ROKEW_OD AND ROK*100+MC<=:ROKEW_DO AND NR_AKT=:NR_AKTEW
UNION ALL
SELECT NR_AKT, ROK, MC, 'NADL100' as TYP_GODZ,
NADL100_1 AS D_1, NADL100_2 AS D_2, NADL100_3 AS D_3, NADL100_4 AS D_4, NADL100_5 AS D_5, NADL100_6 AS D_6, NADL100_7 AS D_7,
NADL100_8 AS D_8, NADL100_9 AS D_9, NADL100_10 AS D_10, NADL100_11 AS D_11, NADL100_12 AS D_12, NADL100_13 AS D_13,
NADL100_14 AS D_14, NADL100_15 AS D_15, NADL100_16 AS D_16, NADL100_17 AS D_17, NADL100_18 AS D_18, NADL100_19 AS D_19,
NADL100_20 AS D_20, NADL100_21 AS D_21, NADL100_22 AS D_22, NADL100_23 AS D_23, NADL100_24 AS D_24, NADL100_25 AS D_25, NADL100_26 AS D_26, NADL100_27 AS D_27, NADL100_28 AS D_28, NADL100_29 AS D_29, NADL100_30 AS D_30, NADL100_31 AS D_31,
0 AS D_32, NADL_SUM100 AS D_33
FROM VKIP_EWPRAC
WHERE NADL_SUM100<>0 AND ROK*100+MC>= :ROKEW_OD AND ROK*100+MC<=:ROKEW_DO AND NR_AKT=:NR_AKTEW
UNION ALL
SELECT NR_AKT, ROK, MC, 'NOCNE ' as TYP_GODZ,
NOC_1 AS D_1, NOC_2 AS D_2, NOC_3 AS D_3, NOC_4 AS D_4, NOC_5 AS D_5, NOC_6 AS D_6, NOC_7 AS D_7,
NOC_8 AS D_8, NOC_9 AS D_9, NOC_10 AS D_10, NOC_11 AS D_11, NOC_12 AS D_12, NOC_13 AS D_13,
NOC_14 AS D_14, NOC_15 AS D_15, NOC_16 AS D_16, NOC_17 AS D_17, NOC_18 AS D_18, NOC_19 AS D_19,
NOC_20 AS D_20, NOC_21 AS D_21, NOC_22 AS D_22, NOC_23 AS D_23, NOC_24 AS D_24, NOC_25 AS D_25, NOC_26 AS D_26, NOC_27 AS D_27, NOC_28 AS D_28, NOC_29 AS D_29, NOC_30 AS D_30, NOC_31 AS D_31,
NOC_SUM AS D_32, 0 AS D_33
FROM VKIP_EWPRAC
WHERE NOC_SUM<>0 AND ROK*100+MC>= :ROKEW_OD AND ROK*100+MC<=:ROKEW_DO AND NR_AKT=:NR_AKTEW
UNION ALL
SELECT NR_AKT, ROK, MC, 'SZKOD ' as TYP_GODZ,
SZKOD_1 AS D_1, SZKOD_2 AS D_2, SZKOD_3 AS D_3, SZKOD_4 AS D_4, SZKOD_5 AS D_5, SZKOD_6 AS D_6, SZKOD_7 AS D_7,
SZKOD_8 AS D_8, SZKOD_9 AS D_9, SZKOD_10 AS D_10, SZKOD_11 AS D_11, SZKOD_12 AS D_12, SZKOD_13 AS D_13,
SZKOD_14 AS D_14, SZKOD_15 AS D_15, SZKOD_16 AS D_16, SZKOD_17 AS D_17, SZKOD_18 AS D_18, SZKOD_19 AS D_19,
SZKOD_20 AS D_20, SZKOD_21 AS D_21, SZKOD_22 AS D_22, SZKOD_23 AS D_23, SZKOD_24 AS D_24, SZKOD_25 AS D_25, SZKOD_26 AS D_26, SZKOD_27 AS D_27, SZKOD_28 AS D_28, SZKOD_29 AS D_29, SZKOD_30 AS D_30, SZKOD_31 AS D_31,
SZKOD_SUM AS D_32, 0 AS D_33
FROM VKIP_EWPRAC
WHERE SZKOD_SUM<>0 AND ROK*100+MC>= :ROKEW_OD AND ROK*100+MC<=:ROKEW_DO AND NR_AKT=:NR_AKTEW

ORDER BY 1,2,3