1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| (SELECT *
FROM crosstab(
'select to_date(datum, ''DD-MM-YYYY''), code, teil
from vermzteildate where code in
(''SBK'',''SNK'',''SHK'', ''SMK'',''Leerrohr'',''SXX'',''NXX'',''EGL'') order by 1,2',
$$VALUES
('SBK'::text), ('SNK'::text), ('SHK'::text), ('SMK'::text), ('Leerrohr'::text), ('SXX'::text), ('NXX'::text), ('EGL'::text)$$)
AS pivot_test ( datum date,
SBK_t bigint, SNK_t bigint, SHK_t bigint, SMK_t bigint, Leerrohr_t bigint, SXX_t bigint, NXX_t bigint, EGL_t bigint) order by datum)
union all
(SELECT *
FROM crosstab(
'select to_date(datum, ''DD-MM-YYYY''), code, laenge
from vermzkabeldate where code in
(''SBK'',''SNK'',''SHK'', ''SMK'',''Leerrohr'',''NMR'',''NRB'',''EGL'') order by 1,2',
$$VALUES
('SBK'::text), ('SNK'::text), ('SHK'::text), ('SMK'::text), ('Leerrohr'::text), ('NMR'::text), ('NRB'::text), ('EGL'::text)$$)
AS pivot_test ( datum date,
SBK_m numeric, SNK_m numeric, SHK_m numeric, SMK_m numeric, Leerrohr_m numeric, NMR_m numeric, NRB_m numeric, EGL_m numeric) order by datum); |
Partager