Browse Source

Computing studiengang_nr, counting heads #2

COStage_0.2_Release
Daniel Quathamer 3 years ago
parent
commit
c747e15110
  1. 59
      src-modules/module/costage/hilfstabellen/costage_st_studien_aggr_fuellen.sql

59
src-modules/module/costage/hilfstabellen/costage_st_studien_aggr_fuellen.sql

@ -56,7 +56,7 @@ and S.matrikelnummer is not null
and SG.studiengangs_typ_kb in ('ESG','TSG') and SG.studiengangs_typ_kb in ('ESG','TSG')
and SA.st_studium_nr=ST.st_studium_nr and SA.st_studium_nr=ST.st_studium_nr
and SA.st_sem_nr=SM.st_sem_nr and SA.st_sem_nr=SM.st_sem_nr
and SA.studienstatustyp not in ('a','o') and SA.studienstatustyp not in ('a')
and ${COSTAGE_STUDENT_FILTER} and ${COSTAGE_STUDENT_FILTER}
--group by 1,2,3,4,5,6,7,8,9,10,11,12,13 --group by 1,2,3,4,5,6,7,8,9,10,11,12,13
; ;
@ -83,21 +83,7 @@ and F.st_sem_nr=tmp_studien.st_sem_nr
and F.fachsemestertyp='FS' and F.fachsemestertyp='FS'
; ;
update tmp_studien
set hssem=F.fachsemester
from costage_st_fachsemester F
where F.st_studium_nr=tmp_studien.st_studium_nr
and F.st_sem_nr=tmp_studien.st_sem_nr
and F.fachsemestertyp='HS'
;
--todo: langsam:
-- update tmp_studien
-- set primaerflag=1
-- where exists (select st_studstamm_nr
-- from costage_st_hauptstudien H
-- where H.st_studstamm_nr=tmp_studien.st_studstamm_nr
-- and H.st_studium_nr=tmp_studien.st_studium_nr
-- and H.st_sem_nr=tmp_studien.st_sem_nr);
select T.*,1::smallint as primaerflag select T.*,1::smallint as primaerflag
into temp tmp_studien2 into temp tmp_studien2
from tmp_studien T, costage_st_hauptstudien H from tmp_studien T, costage_st_hauptstudien H
@ -163,7 +149,32 @@ update tmp_studien2 set kz_rueck_beur_ein=(select val(astat)
from cifx where key=400 from cifx where key=400
and apnr=tmp_studien2.studienstatustyp and apnr=tmp_studien2.studienstatustyp
); );
--wenn die Exmatrikulation zum Semesterende stattfand, wird Status auf Rückgemeldet gesetzt:
update tmp_studien2
set hssem=1 where kz_rueck_beur_ein=1;
;
update tmp_studien2 set studiengang_nr=1 where primaerflag=1;
--Wenn Studium mit Primärflag ein TSG ist, wird die studiengang_nr auf alle anderen TSG des MSG ausgedehnt:
select st_studstamm_nr,semester,st_studiengang_nr_msg
into temp tmp_primaer_msg
from tmp_studien2
where studiengangs_typ_kb ='TSG'
and st_studiengang_nr_msg is not null
and primaerflag=1;
--select * from tmp_primaer_msg;
update tmp_studien2 set studiengang_nr=1 where primaerflag=0
and studiengangs_typ_kb ='TSG'
and exists (select st_studiengang_nr_msg
from tmp_primaer_msg T
where T.st_studstamm_nr=tmp_studien2.st_studstamm_nr
and T.semester=tmp_studien2.semester
and T.st_studiengang_nr_msg=tmp_studien2.st_studiengang_nr_msg
)
;
delete from costage_st_studien_aggr; delete from costage_st_studien_aggr;
@ -200,9 +211,12 @@ select st_studium_nr,
fachsemester, fachsemester,
hssem, hssem,
primaerflag, primaerflag,
rank () over (partition by semester, st_studstamm_nr order by primaerflag desc, --Nun ist studiengang_nr=1 definiert. Die restlichen werden mit RANK ermittelt:
(case when studiengangs_typ_kb='TSG' then st_absz_nr else st_studium_nr end ) (case when studiengang_nr is not null then studiengang_nr
) else
rank () over (partition by semester, st_studstamm_nr,studiengang_nr order by
(case when studiengangs_typ_kb='TSG' then st_absz_nr else st_studium_nr end ))+1
end)
as studiengang_nr, as studiengang_nr,
fach_nr, fach_nr,
unikey, unikey,
@ -216,7 +230,6 @@ select st_studium_nr,
from tmp_studien2 from tmp_studien2
; ;
drop table tmp_studien2;
drop table tmp_studien2; drop table tmp_primaer_msg;

Loading…
Cancel
Save