You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
325 lines
11 KiB
325 lines
11 KiB
47200^Studierendenströme Hochschulvergleich (intern)^--Freemarker Template\ |
|
<#include "SQL_lingua_franca"/>\ |
|
<#include "SuperX_general"/>\ |
|
--dies ist auch das select_stmt der Maske 47200\ |
|
--Autor D. Quathamer 2026\ |
|
<sqlvars>\ |
|
<sqlvar name="msg_used">\ |
|
select sp_table_exists('msg_abp_aggr') from xdummy;\ |
|
</sqlvar>\ |
|
</sqlvars>\ |
|
\ |
|
\ |
|
<#assign inEtl=true />\ |
|
<#if Maskennummer?exists && Maskennummer=47200>\ |
|
<#assign inEtl=false />\ |
|
</#if>\ |
|
\ |
|
<#assign semester_filter ="1=1\ |
|
/* and A.sem_rueck_beur_ein >= <<Seit Semester>> */\ |
|
/* and A.sem_rueck_beur_ein <= <<Bis Semester>> */\ |
|
" />\ |
|
\ |
|
<#assign pruefungstabelle="sos_lab_stg" />\ |
|
<#assign pruefabschlusstyp = "and abschnitt=2" />\ |
|
<#assign pruefstatus = " and pstatus = 'BE'" />\ |
|
<#assign pruefsemester = "sem_d_abg_pruefung" />\ |
|
\ |
|
<#if msg_used==1>\ |
|
<#assign pruefungstabelle="msg_abp_aggr" />\ |
|
<#assign pruefabschlusstyp = " and ${SOS_ABSCHLUSSTYP_GES}" />\ |
|
<#assign pruefstatus = " and pstatus = 'BE' " />\ |
|
<#assign pruefsemester = "sem_der_pruefung" />\ |
|
\ |
|
</#if>\ |
|
<#if inEtl>\ |
|
<#assign filter="1=1" />\ |
|
<#assign matrikel_nr_ausgeben="0" />\ |
|
<#else>\ |
|
<#assign filter="1=1\ |
|
/* and A.stichtag = <<Stichtag>> */\ |
|
/* and <<Hochschulzugangsberechtigung>> */\ |
|
/* and <<Hörerstatus>>*/\ |
|
/* and geschlecht = <<Geschlecht>> */\ |
|
/* and fach_sem_zahl <= <<bis Fachsemester>> */\ |
|
/* and substring('' || sem_rueck_beur_ein from 5 for 1)='<<Semestertyp>>' */\ |
|
" />\ |
|
<#assign matrikel_nr_ausgeben="<<Matrikelnr. ausgeben>>" />\ |
|
\ |
|
<#assign filter= filter + " and " + semester_filter />\ |
|
\ |
|
\ |
|
\ |
|
<#assign filter = filter + " and 's_' || tid_stg in "+Studiengang.allNeededKeysList /> \ |
|
/* <#assign filter = filter + " and '' || ca12_staat in "+Staatsangehörigkeit.allNeededKeysList /> --<<Staatsangehörigkeit>> */\ |
|
/* <#assign filter = filter + " and stg in "+Fächer.allNeededKeysList /> --<<Fächer>> */\ |
|
/* <#assign filter = filter + " and tid_stg in (select L2.tid from lehr_stg_ab L2 where L2.abschluss in "+Abschluss.allNeededKeysList +")" /> --<<Abschluss>> */\ |
|
\ |
|
</#if>\ |
|
\ |
|
\ |
|
create temp table tmp_meta as\ |
|
select\ |
|
H.hs_nr,\ |
|
H.name as hochschulinfo_name,\ |
|
(select datum from systeminfo where tid=7) as datenstand,\ |
|
(select version from db_version where his_system='sxc') as sxc_version,\ |
|
(case when K.apnr=1 then 'HISinOne-BI' else 'SuperX' end)::varchar(50) as dwh_name\ |
|
from hochschulinfo H, konstanten K\ |
|
where K.beschreibung='PLATTFORM'\ |
|
;\ |
|
\ |
|
create temp table tmp_sos_sos\ |
|
as select matrikel_nr,sem_rueck_beur_ein as sem_rueck_beur_ein_max\ |
|
from sos_sos\ |
|
where 1=1\ |
|
/* and matrikel_nr=<<Matrikel-Nr.>> */\ |
|
;\ |
|
\ |
|
create temp table tmp_sos_stud_astat_pro_sem as\ |
|
select \ |
|
dim_studiengang.tid as dim_studiengang_tid,\ |
|
A.sem_rueck_beur_ein as sem_rueck_beur_ein,\ |
|
get_akad_jahr(A.sem_rueck_beur_ein,'P') as jahr,\ |
|
A.kz_rueck_beur_ein as kz_rueck_beur_ein,\ |
|
A.summe as summe,\ |
|
A.matrikel_nr as matrikel_nr,\ |
|
O.sem_rueck_beur_ein_max,\ |
|
S.sem_beginn,\ |
|
S.sem_ende,\ |
|
(case when exists (select L.matrikel_nr\ |
|
from ${pruefungstabelle} L, sos_stichtag I \ |
|
where L.stichtag=I.tid \ |
|
and I.appl_key='2' \ |
|
and L.matrikel_nr=A.matrikel_nr \ |
|
and L.${pruefsemester} <= A.sem_rueck_beur_ein\ |
|
${pruefstatus}\ |
|
${pruefabschlusstyp}\ |
|
) then 1 else 0 end) as hauptpruefung,\ |
|
null::integer as ist_letztes_semester\ |
|
from semester S, tmp_sos_sos O,sos_stg_aggr A\ |
|
left outer join dim_studiengang on (dim_studiengang.tid=A.tid_stg)\ |
|
where O.matrikel_nr=A.matrikel_nr\ |
|
and S.tid=A.sem_rueck_beur_ein\ |
|
and A.studiengang_nr=1\ |
|
and A.fach_nr=1\ |
|
and ${filter}\ |
|
;\ |
|
--Pro Jahr kann es zwei Datensätze geben, für jedes semester\ |
|
--Damit die Hauptprüdfung nur 1x gezählt wird, nur das letzte Semester ermitteln:\ |
|
\ |
|
drop table if exists tmp_letztes_semester;\ |
|
\ |
|
select matrikel_nr,jahr,max(sem_rueck_beur_ein) as letztes_semester\ |
|
into temp tmp_letztes_semester\ |
|
from tmp_sos_stud_astat_pro_sem\ |
|
where hauptpruefung=1\ |
|
group by 1,2;\ |
|
\ |
|
update tmp_sos_stud_astat_pro_sem T set ist_letztes_semester=1 where exists(select L.matrikel_nr\ |
|
from tmp_letztes_semester L where L.matrikel_nr=T.matrikel_nr\ |
|
and L.jahr=T.jahr\ |
|
and L.letztes_semester=T.sem_rueck_beur_ein);\ |
|
\ |
|
drop table if exists tmp_stud;\ |
|
\ |
|
select \ |
|
<#if matrikel_nr_ausgeben=="1">\ |
|
T.matrikel_nr,\ |
|
<#else>\ |
|
null::integer as matrikel_nr,\ |
|
</#if>\ |
|
T.jahr,\ |
|
case when substring('' || T.sem_rueck_beur_ein from 5 for 1)='2' and kz_rueck_beur_ein=3 then summe else 0 end as anfangsbestand,\ |
|
(case when sem_beginn <= current_date and sem_ende >= current_date then '' \ |
|
when sem_rueck_beur_ein_max = sem_rueck_beur_ein then 'nein'\ |
|
when add_sem(T.sem_rueck_beur_ein,1) = T.sem_rueck_beur_ein_max then 'ja'\ |
|
when exists \ |
|
(select S2.matrikel_nr from sos_stg_aggr S2 where S2.matrikel_nr=T.matrikel_nr \ |
|
and S2.sem_rueck_beur_ein=add_sem(T.sem_rueck_beur_ein,1)) then 'ja'\ |
|
when not exists \ |
|
(select S2.matrikel_nr from sos_stg_aggr S2 where S2.matrikel_nr=T.matrikel_nr \ |
|
and S2.sem_rueck_beur_ein=add_sem(T.sem_rueck_beur_ein,1)) then 'nein'\ |
|
else '' end)::varchar(50) as status_folgesem,\ |
|
case when ist_letztes_semester=1 then hauptpruefung else 0 end as hauptpruefung,\ |
|
case when T.kz_rueck_beur_ein in (1,2) then T.summe else 0 end as zugang,\ |
|
case when T.kz_rueck_beur_ein in (1) then T.summe else 0 end as zugang_ersteinschr,\ |
|
0::integer as abgang,\ |
|
T.summe as summe,\ |
|
0::integer as abgang_hauptpr,\ |
|
0::integer as abgang_ohne_hauptpr,\ |
|
0::integer as hauptpr_summe,\ |
|
0::integer as hauptpr_bleibt,\ |
|
null::integer as endbestand\ |
|
into temp tmp_stud\ |
|
from tmp_sos_stud_astat_pro_sem T\ |
|
where 1=1 \ |
|
;\ |
|
\ |
|
-- select * from tmp_stud;\ |
|
\ |
|
update tmp_stud set abgang=summe where status_folgesem='nein';\ |
|
update tmp_stud set abgang_hauptpr=summe where status_folgesem='nein' and hauptpruefung=1;\ |
|
update tmp_stud set abgang_ohne_hauptpr=summe where status_folgesem='nein' and hauptpruefung=0;\ |
|
update tmp_stud set hauptpr_summe=summe where hauptpruefung=1;\ |
|
update tmp_stud set hauptpr_bleibt=summe where hauptpruefung=1 and status_folgesem='ja';\ |
|
\ |
|
--ergebnistabelle:\ |
|
select \ |
|
--zuerst die nicht-Aggregate:\ |
|
jahr,\ |
|
<#if matrikel_nr_ausgeben=="1">\ |
|
matrikel_nr,\ |
|
<#else>\ |
|
null::integer as matrikel_nr,\ |
|
</#if>\ |
|
null::integer as endbestand,\ |
|
--dann die Aggregate:\ |
|
sum(abgang) as abgang,\ |
|
sum(abgang_hauptpr) as abgang_hauptpr,\ |
|
sum(abgang_ohne_hauptpr) as abgang_ohne_hauptpr,\ |
|
sum(hauptpr_summe) as hauptpr_summe,\ |
|
sum(hauptpr_bleibt) as hauptpr_bleibt,\ |
|
sum(anfangsbestand) as anfangsbestand,\ |
|
sum(zugang) as zugang,\ |
|
sum(zugang_ersteinschr) as zugang_ersteinschr,\ |
|
sum(summe) as summe,\ |
|
null::char(1) as dummycol\ |
|
into temp tmp_stud2\ |
|
from tmp_stud\ |
|
where 1=1\ |
|
group by\ |
|
1,2,3\ |
|
;\ |
|
update tmp_stud2 set endbestand= anfangsbestand+zugang-abgang;\ |
|
\ |
|
drop table if exists tmp_sos_stud_astat_pro_sem;\ |
|
drop table if exists tmp_stud;\ |
|
drop table if exists tmp_sos_sos;\ |
|
drop table if exists tmp_letztes_semester;\ |
|
\ |
|
<#if inEtl>\ |
|
\ |
|
delete from sxc_stud_zugang_abgang_aggr\ |
|
where hs_nr in (select distinct M.hs_nr::varchar(255)\ |
|
from tmp_meta M)\ |
|
;\ |
|
\ |
|
insert into sxc_stud_zugang_abgang_aggr(\ |
|
hs_nr,\ |
|
jahr,\ |
|
anfangsbestand,\ |
|
zugang,\ |
|
zugang_ersteinschr,\ |
|
abgang,\ |
|
abgang_hauptpr,\ |
|
abgang_ohne_hauptpr,\ |
|
hauptpr_summe,\ |
|
hauptpr_bleibt,\ |
|
endbestand,\ |
|
datenstand)\ |
|
select \ |
|
M.hs_nr,\ |
|
jahr,\ |
|
anfangsbestand,\ |
|
zugang,\ |
|
zugang_ersteinschr,\ |
|
abgang,\ |
|
abgang_hauptpr,\ |
|
abgang_ohne_hauptpr,\ |
|
hauptpr_summe,\ |
|
hauptpr_bleibt,\ |
|
endbestand,\ |
|
M.datenstand\ |
|
from tmp_stud2, tmp_meta M\ |
|
;\ |
|
\ |
|
drop table tmp_meta;\ |
|
drop table tmp_stud2;\ |
|
\ |
|
<#else>\ |
|
--in Maske\ |
|
select \ |
|
M.hs_nr::varchar(255) as hs_nr,\ |
|
M.hochschulinfo_name,\ |
|
'Prüfungsjahr' as studienjahr_label,\ |
|
'' || jahr as jahr,\ |
|
<#if matrikel_nr_ausgeben=="1">\ |
|
matrikel_nr::varchar as matrikel_nr,\ |
|
</#if>\ |
|
anfangsbestand,\ |
|
zugang,\ |
|
zugang_ersteinschr,\ |
|
abgang,\ |
|
abgang_hauptpr,\ |
|
abgang_ohne_hauptpr,\ |
|
hauptpr_summe,\ |
|
hauptpr_bleibt,\ |
|
endbestand,\ |
|
M.dwh_name,\ |
|
M.datenstand,\ |
|
M.sxc_version\ |
|
from tmp_stud2, tmp_meta M\ |
|
order by 1,2,3,4,5,6,7,8,9,10,11,12,13,14\ |
|
;\ |
|
\ |
|
</#if>^--freemarker template\ |
|
XIL List\ |
|
sizable_columns horizontal_scrolling\ |
|
drop_and_delete movable_columns \ |
|
white_space_color=COLOR_WHITE fixed_columns=1\ |
|
min_heading_height=55\ |
|
Column CID=0 heading_text="Hochschule_ID" center_heading explanation="Amtliche Standortnummer"\ |
|
row_selectable heading_platform readonly\ |
|
width=10 text_size=60\ |
|
Column CID=0 heading_text="Hochschule_NAME" center_heading explanation=""\ |
|
row_selectable heading_platform readonly\ |
|
width=10 text_size=60\ |
|
Column CID=0 heading_text="Semester" center_heading explanation=""\ |
|
row_selectable heading_platform readonly\ |
|
width=10 text_size=60\ |
|
Column CID=0 heading_text="Jahr" center_heading explanation="(WS + darauffolgendes SS, z.B. WiSe 2025/2026 und SoSe 2026 fürs Prüfungsjahr 2026)"\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
<#if <<Matrikelnr. ausgeben>>==1>\ |
|
Column CID=0 heading_text="Matrikel-Nr." center_heading explanation=""\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
</#if>\ |
|
Column CID=0 heading_text="Anfangsbestand" center_heading explanation="Studierende im WiSe"\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
Column CID=0 heading_text="Zugang" center_heading explanation="Studierende (Erst- und Neueinschreiber) im WiSe und SoSe"\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
Column CID=0 heading_text="Zugang_Ersteinschreibung" center_heading explanation="Studierende (Ersteinschreiber) im WiSe und SoSe"\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
Column CID=0 heading_text="Abgang" center_heading explanation="Exmatrikuliert"\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
Column CID=0 heading_text="Abgang_mit_Hauptpruefung" center_heading explanation="Hauptprüfung, im Folgesemester nicht eingeschrieben"\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
Column CID=0 heading_text="Abgang_ohne_Hauptpruefung" center_heading explanation="Keine Hauptprüfung, im Folgesemester nicht eingeschrieben"\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
Column CID=0 heading_text="Hauptpruefung_gesamt" center_heading explanation="Personen mit mindestens einer bestandenen Hauptprüfung vor oder in dem jew. Prüfungsjahr "\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
Column CID=0 heading_text="Hauptpruefung_bleibt" center_heading explanation="Hauptprüfung, im Folgesem.- eingeschrieben"\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
Column CID=0 heading_text="Endbestand" center_heading explanation="Endbestand (Anfangsbestand + Zugang - Abgang)"\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
Column CID=0 heading_text="Quellsystem" center_heading explanation=""\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
Column CID=0 heading_text="Datenstand" center_heading explanation=""\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
Column CID=0 heading_text="Version-Export" center_heading explanation=""\ |
|
row_selectable heading_platform readonly\ |
|
width=5 text_size=60\ |
|
@@@^Studienfach^Anzahl bzw. Anteil^Studierende (Anfangsbestand, Zugang und Abgang) pro Hochschule und Prüfungsjahr (WiSe und darauf folgendes SoSe)^drop table tmp_meta;drop table tmp_stud2;^^2^850^540^^1^ ^
|
|
|