SELECT
t.ОКПО ,
Round(Sum(t.zn201),1) AS [zn201],
Round(Sum(t.zn202),1) AS [zn202],
Round(Sum(t.zn203),1) AS [zn203],
Round(Sum(t.zn204),1) AS [zn204],
Round(Sum(t.zn205),1) AS [zn205],
Round(Sum(t.zn206),1) AS [zn206],
Round(Sum(t.zn207),1) AS [zn207],
Round(Sum(t.zn208),1) AS [zn208],
Round(Sum(t.zn209),1) AS [zn209],
Round(Sum(t.zn210),1) AS [zn210],
Round(Sum(t.zn211),1) AS [zn211],
Round(Sum(t.zn212),1) AS [zn212]
FROM (
SELECT
t1.ОКПО,
t1.zn201,
t1.zn202,
t1.zn203,
t1.zn204,
t1.zn205,
t1.zn206,
t1.zn207,
t1.zn208,
t1.zn209,
t1.zn210,
t1.zn211,
t1.zn212
FROM data_1001 t1
UNION ALL
SELECT
t2.ОКПО,
-t2.zn201,
-t2.zn202,
-t2.zn203,
-t2.zn204,
-t2.zn205,
-t2.zn206,
-t2.zn207,
-t2.zn208,
-t2.zn209,
-t2.zn210,
-t2.zn211,
-t2.zn212
FROM data_1001_ук t2
) t
GROUP BY t.ОКПО;
|