@ -1,6 +1,8 @@
@@ -1,6 +1,8 @@
- - freemarker template
drop table if exists tmp_studien ;
drop table if exists tmp_studien2 ;
SELECT
SM . semester_tid as semester ,
@ -23,14 +25,15 @@ S.ca12_staat,
@@ -23,14 +25,15 @@ S.ca12_staat,
S . second_nationality ,
SG . fachkennzeichen ,
ST . studienform_statistik_code ,
null : : integer as st_studiengang_nr_msg ,
( case when SG . studiengangs_typ_kb in ( ' MSG ' ) then SG . st_studiengang_nr else null : : integer end ) as st_studiengang_nr_msg ,
null : : integer as st_studiengang_nr_msg_primaerflag ,
null : : integer as st_studiengang_nr_tsg ,
( case when SG . studiengangs_typ_kb in ( ' TSG ' ) then SG . st_studiengang_nr else null : : integer end ) as st_studiengang_nr_tsg ,
null : : integer as studienfach_sortierung ,
null : : char ( 10 ) as hrst ,
null : : integer as fachsemester ,
null : : integer as hssem ,
null : : char ( 10 ) as statustyp ,
( case when SG . studiengangs_typ_kb in ( ' TSG ' ) then SA . studienstatustyp else null : : char ( 10 ) end ) as statustyp_tsg ,
0 : : smallint as tsg_generated ,
- - 0 : : smallint as primaerflag ,
null : : integer as studiengang_nr ,
null : : integer as fach_nr ,
@ -40,7 +43,7 @@ null::date as ruebeudat,
@@ -40,7 +43,7 @@ null::date as ruebeudat,
null : : date as endedat ,
null : : smallint as kz_rueck_beur_ein ,
null : : char ( 10 ) as hzb_art ,
rank ( ) over ( partition by SM . st_sem_nr , S . st_studstamm_nr , SG . studiengangs_identifikator order by SA . gueltig_ab desc ) as status_historie
rank ( ) over ( partition by SM . st_sem_nr , S . st_studstamm_nr , SG . studiengangs_identifikator order by SA . gueltig_ab desc ) as status_historie
into temp tmp_studien
FROM costage_st_studierendenstammdaten S ,
costage_st_studien ST ,
@ -55,20 +58,14 @@ and ST.st_studiengang_nr=SG.st_studiengang_nr
@@ -55,20 +58,14 @@ and ST.st_studiengang_nr=SG.st_studiengang_nr
and S . matrikelnummer is not null
- - and SM . semester_tid > = 20171
-- and SM.semester_tid <= 20171
- - and S . matrikelnummer in ( ' 1415093 ' )
and SG . studiengangs_typ_kb in ( ' ESG ' , ' TSG ' )
and SG . studiengangs_typ_kb in ( ' ESG ' , ' TSG ' , ' MSG ' )
and SA . st_studium_nr = ST . st_studium_nr
and SA . st_sem_nr = SM . st_sem_nr
and SA . gueltig_ab < = SM . semester_ende - - nur letzter Status im jew . Semester interessiert , nicht danach
and SA . studienstatustyp not in ( ' a ' , ' o ' )
and $ { COSTAGE_STUDENT_FILTER }
- - group by 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13
;
-- select * from tmp_studien
-- update tmp_studien
-- set abschluss_str=A.name
-- from costage_st_abschlussziele_lokal A
-- where A.st_absz_nr=tmp_studien.abschluss
-- ;
update tmp_studien
set hrst = H . hoererstatus_kb
@ -102,6 +99,7 @@ from tmp_studien T, costage_st_hauptstudien H
@@ -102,6 +99,7 @@ from tmp_studien T, costage_st_hauptstudien H
and H . st_studium_nr = T . st_studium_nr
and H . st_sem_nr = T . st_sem_nr
and status_historie = 1
and T . studiengangs_typ_kb in ( ' ESG ' , ' TSG ' )
;
- - Studiengänge ohne Primärflag :
insert into tmp_studien2
@ -111,10 +109,10 @@ on (H.st_studstamm_nr=T.st_studstamm_nr
@@ -111,10 +109,10 @@ on (H.st_studstamm_nr=T.st_studstamm_nr
and H . st_studium_nr = T . st_studium_nr
and H . st_sem_nr = T . st_sem_nr )
where T . status_historie = 1
and T . studiengangs_typ_kb in ( ' ESG ' , ' TSG ' )
and H . st_studstamm_nr is null
;
;
drop table tmp_studien ;
- - Ermittlung msg :
@ -125,6 +123,125 @@ and ST.st_studstamm_nr=tmp_studien2.st_studstamm_nr
@@ -125,6 +123,125 @@ and ST.st_studstamm_nr=tmp_studien2.st_studstamm_nr
and M . st_studiengang_nr_tsg = tmp_studien2 . st_studiengang_nr
and tmp_studien2 . studiengangs_typ_kb = ' TSG '
;
update tmp_studien2 set studienstatustyp = null ;
- - Ermittlung status bei TSG aus MSG :
update tmp_studien2 set studienstatustyp = T . studienstatustyp
from tmp_studien T
where T . st_studiengang_nr = tmp_studien2 . st_studiengang_nr_msg
and T . st_studstamm_nr = tmp_studien2 . st_studstamm_nr
and T . st_sem_nr = tmp_studien2 . st_sem_nr
and T . status_historie = 1
and tmp_studien2 . studiengangs_typ_kb = ' TSG '
;
drop table if exists tmp_fehlend ;
- - fehlende TSG nachtragen :
select T . st_studium_nr ,
T . studienstatustyp ,
T . st_studienstatus_nr ,
T . st_studiengang_nr_msg ,
T . st_sem_nr ,
T . st_studstamm_nr ,
T . beginn_datum ,
T . gueltig_ab
into temp tmp_fehlend
from tmp_studien T
left outer join tmp_studien2 T2
on ( T2 . st_studiengang_nr_msg = T . st_studiengang_nr
and T2 . st_studstamm_nr = T . st_studstamm_nr
and T2 . studiengangs_typ_kb = ' TSG '
and T . st_sem_nr = T2 . st_sem_nr )
where T2 . st_studstamm_nr is null
and T . studienstatustyp in ( ' B ' , ' E ' , ' I ' ) - - nur tatsächlich eingeschrieben
- - and T . st_sem_nr = 180
;
insert into tmp_studien2 ( semester ,
st_absz_nr ,
st_skz_nr ,
studiengangs_identifikator ,
studiengangs_bezeichnung ,
st_sem_nr ,
st_studium_nr ,
st_studstamm_nr ,
st_studiengang_nr ,
studiengangs_typ_kb ,
studienstatustyp ,
st_studienstatus_nr ,
beginn_datum ,
gueltig_ab ,
matrikelnummer ,
geschlecht ,
ca12_staat ,
second_nationality ,
fachkennzeichen ,
studienform_statistik_code ,
st_studiengang_nr_msg ,
st_studiengang_nr_tsg ,
hrst ,
hssem ,
statustyp_tsg ,
tsg_generated ,
primaerflag ,
hzb_art ,
fachsemester )
select E . semester_tid ,
st_absz_nr ,
S . st_skz_nr ,
S . studiengangs_identifikator ,
S . studiengangs_bezeichnung ,
T . st_sem_nr ,
S . st_studium_nr ,
S . st_studstamm_nr ,
S . st_studiengang_nr ,
S . studiengangs_typ_kb ,
T . studienstatustyp ,
T . st_studienstatus_nr ,
T . beginn_datum ,
T . gueltig_ab ,
S . matrikelnummer ,
S . geschlecht ,
S . ca12_staat ,
S . second_nationality ,
S . fachkennzeichen ,
S . studienform_statistik_code ,
S . st_studiengang_nr_msg ,
S . st_studiengang_nr_tsg ,
S . hrst ,
S . hssem ,
null : : char ( 10 ) as statustyp_tsg ,
1 as tsg_generated ,
S . primaerflag ,
S . hzb_art ,
max ( S . fachsemester )
from tmp_fehlend T , tmp_studien2 S , costage_st_semester E
where T . st_studiengang_nr_msg = S . st_studiengang_nr_msg
and T . st_studstamm_nr = S . st_studstamm_nr
and S . studiengangs_typ_kb = ' TSG '
and T . st_sem_nr ! = S . st_sem_nr
and E . st_sem_nr = T . st_sem_nr
group by 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 23 , 24 , 25 , 26 , 27 , 28
;
- - statustyp_stg nachladen :
update tmp_studien2 set statustyp_tsg = S . statustyp_tsg
from tmp_studien S
where tmp_studien2 . st_studium_nr = S . st_studium_nr
and tmp_studien2 . st_studstamm_nr = S . st_studstamm_nr
and S . studiengangs_typ_kb = ' TSG '
and tmp_studien2 . tsg_generated = 1
and tmp_studien2 . fachsemester = S . fachsemester
;
drop table tmp_studien ;
- - Ermittlung fach_nr :
update tmp_studien2 set fach_nr = M . studienfach_sortierung
@ -137,18 +254,6 @@ and tmp_studien2.studiengangs_typ_kb ='TSG'
@@ -137,18 +254,6 @@ and tmp_studien2.studiengangs_typ_kb ='TSG'
update tmp_studien2 set fach_nr = 1
where fach_nr is null ;
- - Ermittlung status bei TSG aus MSG :
update tmp_studien2 set studienstatustyp = SA . studienstatustyp
from costage_st_studienstatus SA , costage_st_studiengaenge SG , costage_st_studien ST
where SG . st_studiengang_nr = tmp_studien2 . st_studiengang_nr_msg
and ST . st_studium_nr = SA . st_studium_nr
and ST . st_studstamm_nr = tmp_studien2 . st_studstamm_nr
and SA . st_sem_nr = tmp_studien2 . st_sem_nr
and SA . gueltig_ab = tmp_studien2 . gueltig_ab
and tmp_studien2 . studiengangs_typ_kb = ' TSG '
;
update tmp_studien2 set unikey = K . unikey
@ -208,6 +313,8 @@ st_studium_nr,
@@ -208,6 +313,8 @@ st_studium_nr,
st_studiengang_nr ,
st_studienstatus_nr ,
statustyp ,
statustyp_tsg ,
tsg_generated ,
hrst ,
semester ,
fachsemester ,
@ -231,7 +338,9 @@ select st_studium_nr,
@@ -231,7 +338,9 @@ select st_studium_nr,
st_studiengang_nr ,
st_studienstatus_nr ,
studienstatustyp ,
hrst ,
statustyp_tsg ,
tsg_generated ,
hrst ,
semester ,
fachsemester ,
hssem ,
@ -291,6 +400,8 @@ st_studium_nr,
@@ -291,6 +400,8 @@ st_studium_nr,
st_studiengang_nr ,
st_studienstatus_nr ,
statustyp ,
statustyp_tsg ,
tsg_generated ,
hrst ,
semester ,
fachsemester ,
@ -314,6 +425,8 @@ select st_studium_nr,
@@ -314,6 +425,8 @@ select st_studium_nr,
st_studiengang_nr ,
st_studienstatus_nr ,
studienstatustyp ,
statustyp_tsg ,
tsg_generated ,
hrst ,
semester ,
fachsemester ,
@ -414,9 +527,10 @@ where A.st_studstamm_nr=costage_st_studien_aggr.st_studstamm_nr
@@ -414,9 +527,10 @@ where A.st_studstamm_nr=costage_st_studien_aggr.st_studstamm_nr
and A . st_adresse_typ = ' H '
;
drop table tmp_studien2 ;
drop table tmp_primaer_msg ;
drop table temp_tmp_studien2 ;
drop table tmp_fehlend ;