|
|
|
|
@ -1,4 +1,6 @@
@@ -1,4 +1,6 @@
|
|
|
|
|
drop table if exists tmp_nrw_durchschnitt; |
|
|
|
|
drop table if exists tmp_luf_aktiv; |
|
|
|
|
drop table if exists tmp_luf_aktiv_sum; |
|
|
|
|
|
|
|
|
|
CREATE TABLE tmp_nrw_durchschnitt |
|
|
|
|
( |
|
|
|
|
@ -8,16 +10,21 @@ CREATE TABLE tmp_nrw_durchschnitt
@@ -8,16 +10,21 @@ CREATE TABLE tmp_nrw_durchschnitt
|
|
|
|
|
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 |
|
|
|
|
; |
|
|
|
|
create table tmp_luf_aktiv |
|
|
|
|
( |
|
|
|
|
hs_nr char(10), |
|
|
|
|
luf char(10), |
|
|
|
|
jahr integer, |
|
|
|
|
aktiv integer |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
create table tmp_luf_aktiv_sum |
|
|
|
|
( |
|
|
|
|
luf char(10), |
|
|
|
|
jahr integer, |
|
|
|
|
aktiv_sum integer |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delete from sxc_zahl_wert |
|
|
|
|
where |
|
|
|
|
@ -36,8 +43,7 @@ INSERT INTO sxc_zahl_wert
@@ -36,8 +43,7 @@ INSERT INTO sxc_zahl_wert
|
|
|
|
|
ch110_institut, |
|
|
|
|
sxc_bestand_id, |
|
|
|
|
wert, |
|
|
|
|
generic_dim1, |
|
|
|
|
generic_dim2 |
|
|
|
|
generic_dim1 |
|
|
|
|
) |
|
|
|
|
select |
|
|
|
|
W.hs_nr, |
|
|
|
|
@ -48,24 +54,105 @@ select
@@ -48,24 +54,105 @@ select
|
|
|
|
|
W.ch110_institut, |
|
|
|
|
W.sxc_bestand_id, |
|
|
|
|
W.wert, |
|
|
|
|
W.generic_dim1, |
|
|
|
|
D.nrw_durchschnitt |
|
|
|
|
W.generic_dim1 |
|
|
|
|
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 |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
-- Folgend wird der NRW-Durchschnitt berechnet. Dafür wird |
|
|
|
|
-- 1) tmp_sxc_zahl_wert geleert und aus sxc_zahl_wert neu befüllt, damit alle Daten in die Berechnung einfließen |
|
|
|
|
-- tmp_sxc_zahl_wert wird für Hilfsspalte anz_hs_mit_aktivem_luf benötigt |
|
|
|
|
-- 2) Anzahl der HS mit aktivem LuF ermittelt für Nenner bei NRW-Durchschnitt |
|
|
|
|
-- LuF ist aktiv wenn Studierende Köpfe > 0 |
|
|
|
|
-- 3) NRW-Durchschnitt in tmp_sxc_zahl_wert berechnet |
|
|
|
|
-- 4) Update NRW-Durchschnitt auf sxc_zahl_wert |
|
|
|
|
|
|
|
|
|
drop table if exists tmp_sxc_zahl_wert; |
|
|
|
|
drop table if exists tmp_nrw_durchschnitt; |
|
|
|
|
|
|
|
|
|
-- 1) tmp_sxc_zahl_wert geleert und aus sxc_zahl_wert neu befüllt |
|
|
|
|
delete from tmp_sxc_zahl_wert; |
|
|
|
|
insert into tmp_sxc_zahl_wert( |
|
|
|
|
tid, |
|
|
|
|
hs_nr, |
|
|
|
|
kenn_zahl, |
|
|
|
|
jahr, |
|
|
|
|
sem, |
|
|
|
|
ch110_institut, |
|
|
|
|
sxc_bestand_id, |
|
|
|
|
wert, |
|
|
|
|
generic_dim1, |
|
|
|
|
generic_dim2, |
|
|
|
|
bland) |
|
|
|
|
select |
|
|
|
|
tid, |
|
|
|
|
hs_nr, |
|
|
|
|
kenn_zahl, |
|
|
|
|
jahr, |
|
|
|
|
sem, |
|
|
|
|
ch110_institut, |
|
|
|
|
sxc_bestand_id, |
|
|
|
|
wert, |
|
|
|
|
generic_dim1, |
|
|
|
|
generic_dim2, |
|
|
|
|
bland |
|
|
|
|
from sxc_zahl_wert |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 2) Anzahl der HS mit aktivem LuF ermittelt |
|
|
|
|
insert into tmp_luf_aktiv |
|
|
|
|
select |
|
|
|
|
hs_nr, |
|
|
|
|
generic_dim1, |
|
|
|
|
jahr, |
|
|
|
|
1 |
|
|
|
|
from tmp_sxc_zahl_wert |
|
|
|
|
where |
|
|
|
|
kenn_zahl='stud' |
|
|
|
|
and wert > 0 |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
insert into tmp_luf_aktiv_sum |
|
|
|
|
select |
|
|
|
|
luf, |
|
|
|
|
jahr, |
|
|
|
|
sum(aktiv) as aktiv_sum |
|
|
|
|
from tmp_luf_aktiv |
|
|
|
|
where hs_nr in ('1130','1480','1140','1080','1090','1100','1110','1120','0080','0121','0130','0140') |
|
|
|
|
group by 1,2 |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
update tmp_sxc_zahl_wert set anz_hs_mit_aktivem_luf=S.aktiv_sum |
|
|
|
|
from tmp_luf_aktiv_sum S |
|
|
|
|
where S.luf=tmp_sxc_zahl_wert.generic_dim1 |
|
|
|
|
and S.jahr=tmp_sxc_zahl_wert.jahr |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
-- 3) NRW-Durchschnitt in tmp_sxc_zahl_wert berechnet |
|
|
|
|
insert into tmp_nrw_durchschnitt |
|
|
|
|
select |
|
|
|
|
jahr, |
|
|
|
|
kenn_zahl, |
|
|
|
|
generic_dim1 as lfb, |
|
|
|
|
case when kenn_zahl like '%_proz%' then sum(wert)/anz_hs_mit_aktivem_luf*100 else sum(wert)/anz_hs_mit_aktivem_luf 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,anz_hs_mit_aktivem_luf |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
-- 4) Update NRW-Durchschnitt auf sxc_zahl_wert |
|
|
|
|
update sxc_zahl_wert set generic_dim2=N.nrw_durchschnitt |
|
|
|
|
from tmp_nrw_durchschnitt N |
|
|
|
|
where sxc_zahl_wert.jahr=N.jahr |
|
|
|
|
and sxc_zahl_wert.kenn_zahl=N.kenn_zahl |
|
|
|
|
and sxc_zahl_wert.generic_dim1=N.lfb |
|
|
|
|
and sxc_zahl_wert.sxc_bestand_id=1 |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
drop table if exists tmp_sxc_zahl_wert; |
|
|
|
|
drop table if exists tmp_nrw_durchschnitt; |
|
|
|
|
--drop table if exists tmp_luf_aktiv; |
|
|
|
|
--drop table if exists tmp_luf_aktiv_sum; |
|
|
|
|
|
|
|
|
|
|