Browse Source

Added Union in the final insert

COStage_0.2_Release
apandey 3 years ago
parent
commit
cb1d0b27d6
  1. 52
      src-modules/module/costage/hilfstabellen/costage_st_studien_aggr_fuellen.sql

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

@ -52,7 +52,7 @@ and ST.st_studiengang_nr=SG.st_studiengang_nr @@ -52,7 +52,7 @@ 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 ='7322871'
--and S.matrikelnummer in ('1415093')
and SG.studiengangs_typ_kb in ('ESG','TSG')
and SA.st_studium_nr=ST.st_studium_nr
and SA.st_sem_nr=SM.st_sem_nr
@ -230,6 +230,7 @@ select st_studium_nr, @@ -230,6 +230,7 @@ select st_studium_nr,
-- (case when studiengangs_typ_kb='TSG' then st_absz_nr else st_studium_nr end ))+1
-- end)
-- as studiengang_nr,
(case when studiengangs_typ_kb ='TSG' then
(case when primaerflag =1
then 1
@ -244,8 +245,50 @@ select st_studium_nr, @@ -244,8 +245,50 @@ select st_studium_nr,
(case when primaerflag =1
then 1
else
dense_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) end ) as studiengang_nr2,
dense_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) end ) as studiengang_nr2,
(case when primaerflag =1 then 1
else
dense_rank () over (partition by semester, st_studstamm_nr,studiengang_nr
order by fach_nr)
end) as fach_nr,
unikey,
beginn_datum as anfdat,
(case when studienstatustyp not in ('Z','X') then null::date
else gueltig_ab end) as ruebeudat,
(case when studienstatustyp in ('Z','X') then gueltig_ab
else null::date end) as endedat,
studienform_statistik_code as stufrm,
kz_rueck_beur_ein
from tmp_studien2
-- where semester = 20202
--and matrikelnummer = '5545242'
where kz_rueck_beur_ein is not null
-- The below code appends the data for the records having kz_rueck_beur_ein as NULL, this data could be helpful for other diagonostic purpose; here this is segregated
-- from above to accomodate ranking in studiengangNummer field
union
select st_studium_nr,
st_studstamm_nr,
matrikelnummer,
st_studiengang_nr,
st_studienstatus_nr,
studienstatustyp,
hrst,
semester,
fachsemester,
hssem,
primaerflag,
--Nun ist studiengang_nr=1 definiert. Die restlichen werden mit RANK ermittelt:
-- (case when studiengang_nr is not null then studiengang_nr
-- else
-- dense_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,
cast (NULL as int) as studiengang_nr2,
(case when primaerflag =1 then 1
else
dense_rank () over (partition by semester, st_studstamm_nr,studiengang_nr
@ -260,6 +303,9 @@ select st_studium_nr, @@ -260,6 +303,9 @@ select st_studium_nr,
studienform_statistik_code as stufrm,
kz_rueck_beur_ein
from tmp_studien2
--where semester = 20202
-- and matrikelnummer = '5847370'
where kz_rueck_beur_ein is null
;
drop table tmp_studien2;

Loading…
Cancel
Save