SQL skript pro generovani obalek.
This commit is contained in:
parent
dc24f1017a
commit
154c02e8f7
1 changed files with 25 additions and 0 deletions
25
obalky.sql
Normal file
25
obalky.sql
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
WITH akt_rocnik AS (
|
||||||
|
SELECT rocnik FROM seminar_rocniky
|
||||||
|
WHERE id=(SELECT aktualni_rocnik_id FROM seminar_nastaveni)
|
||||||
|
), id_rocniku AS (
|
||||||
|
SELECT id FROM seminar_rocniky
|
||||||
|
WHERE rocnik=(SELECT * FROM akt_rocnik) OR rocnik=(SELECT * FROM akt_rocnik)-1
|
||||||
|
), id_cisel AS (
|
||||||
|
SELECT seminar_cisla.id FROM seminar_cisla
|
||||||
|
INNER JOIN id_rocniku ON rocnik_id=id_rocniku.id
|
||||||
|
), problemy AS (
|
||||||
|
SELECT seminar_problemy.id FROM seminar_problemy
|
||||||
|
INNER JOIN id_cisel ON cislo_zadani_id = id_cisel.id
|
||||||
|
), resitele AS(
|
||||||
|
SELECT DISTINCT resitel_id FROM seminar_reseni
|
||||||
|
INNER JOIN problemy ON problem_id=problemy.id
|
||||||
|
)
|
||||||
|
SELECT pohlavi_muz,jmeno,prijmeni,NULL,ulice,mesto,psc,stat FROM seminar_resitele
|
||||||
|
INNER JOIN resitele ON seminar_resitele.id=resitel_id
|
||||||
|
WHERE zasilat='domu'
|
||||||
|
UNION
|
||||||
|
SELECT res.pohlavi_muz,res.jmeno,res.prijmeni,sk.nazev,sk.ulice,sk.mesto,sk.psc,sk.stat
|
||||||
|
FROM seminar_resitele AS res
|
||||||
|
INNER JOIN resitele ON res.id=resitel_id
|
||||||
|
INNER JOIN seminar_skoly AS sk ON sk.id=skola_id
|
||||||
|
WHERE zasilat='do_skoly'
|
Loading…
Reference in a new issue