From 154c02e8f700a0bd9d9d9192c96beb605e10ad77 Mon Sep 17 00:00:00 2001 From: "Tomas \"Jethro\" Pokorny" Date: Sat, 24 Oct 2015 16:38:38 +0200 Subject: [PATCH] SQL skript pro generovani obalek. --- obalky.sql | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 obalky.sql diff --git a/obalky.sql b/obalky.sql new file mode 100644 index 00000000..d503fe62 --- /dev/null +++ b/obalky.sql @@ -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' \ No newline at end of file