5 changed files with 128 additions and 18 deletions
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
drop table if exists tmp_nrw_durchschnitt; |
||||
|
||||
CREATE TABLE tmp_nrw_durchschnitt |
||||
( |
||||
jahr integer, |
||||
kenn_zahl char(100), |
||||
lfb char(100), |
||||
nrw_durchschnitt numeric |
||||
); |
||||
|
||||
insert into tmp_nrw_durchschnitt |
||||
select |
||||
jahr, |
||||
kenn_zahl, |
||||
generic_dim1 as lfb, |
||||
case when kenn_zahl like '%_proz%' then sum(wert)/12*100 else sum(wert)/12 end as nrw_durchschnitt |
||||
from tmp_sxc_zahl_wert |
||||
where hs_nr in ('1130','1480','1140','1080','1090','1100','1110','1120','0080','0121','0130','0140') |
||||
group by jahr,kenn_zahl,lfb |
||||
; |
||||
|
||||
delete from sxc_zahl_wert |
||||
where |
||||
sxc_bestand_id=1 |
||||
and jahr in (select jahr from tmp_sxc_zahl_wert) |
||||
and hs_nr in (select hs_nr from tmp_sxc_zahl_wert) |
||||
; |
||||
|
||||
INSERT INTO sxc_zahl_wert |
||||
( |
||||
hs_nr, |
||||
kenn_zahl, |
||||
jahr, |
||||
sem, |
||||
bland, |
||||
ch110_institut, |
||||
sxc_bestand_id, |
||||
wert, |
||||
generic_dim1, |
||||
generic_dim2 |
||||
) |
||||
select |
||||
W.hs_nr, |
||||
W.kenn_zahl, |
||||
W.jahr, |
||||
W.sem, |
||||
W.bland, |
||||
W.ch110_institut, |
||||
W.sxc_bestand_id, |
||||
W.wert, |
||||
W.generic_dim1, |
||||
D.nrw_durchschnitt |
||||
from tmp_sxc_zahl_wert W |
||||
left outer join tmp_nrw_durchschnitt D on ( |
||||
W.jahr=D.jahr |
||||
and W.kenn_zahl=D.kenn_zahl |
||||
and W.generic_dim1=D.lfb |
||||
and W.sxc_bestand_id=1) |
||||
where |
||||
hs_nr is not null |
||||
order by |
||||
sxc_bestand_id,1,2,3,4 |
||||
; |
||||
|
||||
|
||||
drop table if exists tmp_sxc_zahl_wert; |
||||
drop table if exists tmp_nrw_durchschnitt; |
||||
|
||||
|
||||
|
||||
drop table if exists tmp_nrw_durchschnitt; |
||||
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
update tmp_sxc_zahl_wert set |
||||
hs_nr=M.target_value |
||||
from |
||||
sxc_mapping_bestand M |
||||
where |
||||
M.sxc_bestand_id=1 |
||||
and M.object_type='Hochschule' |
||||
and M.object_value=tmp_sxc_zahl_wert.hs_nr_str |
||||
; |
||||
|
||||
|
||||
update tmp_sxc_zahl_wert |
||||
set wert = |
||||
case |
||||
when wert_str != '--' |
||||
and wert_str is not null |
||||
and wert_str <> '' |
||||
then cast(replace(wert_str, ',' , '.') as decimal(30,20)) * 100 |
||||
else null |
||||
end |
||||
where kenn_zahl like '%_proz%' |
||||
; |
||||
|
||||
update tmp_sxc_zahl_wert |
||||
set wert = |
||||
case |
||||
when wert_str != '--' |
||||
and wert_str is not null |
||||
and wert_str <> '' |
||||
then cast(replace(wert_str, ',' , '.') as decimal(30,20)) |
||||
else null |
||||
end |
||||
where wert is null |
||||
; |
||||
|
||||
update tmp_sxc_zahl_wert set sxc_bestand_id=1; -- MKW NRW Hochschulkennzahlen |
||||
update tmp_sxc_zahl_wert set bland=5; -- NRW |
||||
|
||||
|
||||
Loading…
Reference in new issue