SELECT
1 AS
DOTAZ#_1, STROJVUDCE.* FROM
STROJVUDCE WHERE
PRACOVNIK_RC = 500521072;
SELECT
* FROM
OPRAVNENI WHERE
(OPRAVNEN_PRACOVNIK_RC = 7708020118) AND
(K_RIZENI_TYP_VUZ_ID_TYP_VUZ = 5);
SELECT
* FROM
PRACOVNIK WHERE
RC = 6203150060;
SELECT
Distinct
CISLO_SMENY, SKUPINA_P_POPIS, SMEROVKA, ID_PRACOVISTE FROM
SMENA CROSS
JOIN
PRACOVISTE
WHERE
POCET_MIST >
( SELECT
COUNT
(*) FROM
ZAMESTNANI
WHERE
(ID_PRACOVISTE = PRACOVISTE_ID_PRACOVISTE) AND
(SMENA_CISLO_SMENY = CISLO_SMENY) )
ORDER
BY
ID_PRACOVISTE;
SELECT
Distinct
5 AS
DOTAZ#_1, CISLO_SMENY, SKUPINA_P_POPIS, SMEROVKA, ID_PRACOVISTE,
POCET_MIST - ( SELECT
COUNT
(*) FROM
ZAMESTNANI WHERE
(ID_PRACOVISTE = PRACOVISTE_ID_PRACOVISTE) AND
(SMENA_CISLO_SMENY = CISLO_SMENY) )
AS
SCHAZI
FROM
SMENA CROSS
JOIN
PRACOVISTE
WHERE
POCET_MIST >
( SELECT
COUNT
(*) FROM
ZAMESTNANI
WHERE
(ID_PRACOVISTE = PRACOVISTE_ID_PRACOVISTE) AND
(SMENA_CISLO_SMENY = CISLO_SMENY) )
ORDER
BY
ID_PRACOVISTE;
SELECT
PRACOVNIK_RC FROM
( SELECT
* FROM
OBECNY MINUS
SELECT
PRACOVNIK_RC, SKUPINA_Z_POPIS FROM
OBECNY NATURAL
JOIN
ZAMESTNANI WHERE
SMENA_CISLO_SMENY = 1 )
JOIN
SKUPINA_PRACOVNIKU ON
(SKUPINA_Z_POPIS = POPIS )
WHERE
OD_PRACOVIST_POPIS = 'SERVIS';
SELECT
JMENO, PRACOVNIK_RC,
(SELECT
COUNT
(*) FROM
(SELECT
PRACOVISTE_ID_PRACOVISTE, SMENA_CISLO_SMENY, PRACOVNIK_RC AS
X FROM
ZAMESTNANI) WHERE
PRACOVNIK_RC = X) AS
VYTIZENOST
FROM
( SELECT
* FROM
OBECNY MINUS
SELECT
PRACOVNIK_RC, SKUPINA_Z_POPIS FROM
OBECNY NATURAL
JOIN
ZAMESTNANI WHERE
SMENA_CISLO_SMENY = 1 )
JOIN
SKUPINA_PRACOVNIKU ON
(SKUPINA_Z_POPIS = POPIS)
JOIN
PRACOVNIK ON
(PRACOVNIK_RC = RC )
WHERE
OD_PRACOVIST_POPIS = 'SERVIS'
ORDER
BY
VYTIZENOST;
ALTER
session set NLS_DATE_FORMAT = 'hh24:mi';
INSERT
into SPOJ (ZRYCHLENY, OSOBNI_NAKLADNI, ID_SPOJ, JEDE_SOBOTA, JEDE_NEDELE, JEDE_SVATEK, PRIJEZD_SPOJ, ODJEZD_SPOJ, POSUN_PRACOVNIK_RC, RIZENI_PRACOVNIK_RC)
values ( 0, 0, 999, 0, 0, 0, '16:00', '11:00', 500813051, 500521072);
SELECT
ID_VUZ FROM
VUZ
MINUS
SELECT
ID_VUZ FROM
VUZ V JOIN
RAZENI R ON
(V.ID_VUZ = R.VUZ_ID_VUZ)
JOIN
SPOJ S ON
(R.SPOJ_ID_SPOJ = S.ID_SPOJ)
JOIN
SPOJ X ON
(X.ID_SPOJ = 999) AND
(S.ODJEZD_SPOJ < X.PRIJEZD_SPOJ) AND
(S.PRIJEZD_SPOJ > X.ODJEZD_SPOJ)
MINUS
SELECT
ID_VUZ FROM
VUZ V JOIN
LOKOMOTIVA L ON
(V.ID_VUZ = L.VUZ_ID_VUZ)
JOIN
POHON P ON
(L.VUZ_ID_VUZ = P.LOKOMOTIVA_VUZ_ID_VUZ)
JOIN
SPOJ S ON
(P.SPOJ_ID_SPOJ = S.ID_SPOJ)
JOIN
SPOJ X ON
(X.ID_SPOJ = 999) AND
(S.ODJEZD_SPOJ < X.PRIJEZD_SPOJ) AND
(S.PRIJEZD_SPOJ > X.ODJEZD_SPOJ);
DELETE
FROM
SPOJ WHERE
ID_SPOJ = 999;
ALTER
session set NLS_DATE_FORMAT = 'hh24:mi';
SELECT
KOLEJ FROM
ZASTAVKA WHERE
(STANICE_ID_STANICE = 9) AND
(ODJEZD > '10:00') AND
(PRIJEZD < '14:00');
SELECT
10 AS
DOTAZ#_1, ZRYCHLENY, ID_SPOJ, JEDE_SOBOTA, JEDE_NEDELE, JEDE_SVATEK FROM
SPOJ WHERE
ID_SPOJ = 8;
SELECT
NAZEV, MESTO, KOLEJ, NASTUPISTE, PRIJEZD, ODJEZD FROM
SPOJ JOIN
ZASTAVKA ON
(ID_SPOJ = SPOJ_ID_SPOJ)
JOIN
STANICE ON
(STANICE_ID_STANICE = ID_STANICE)
WHERE
ID_SPOJ = 3;
SELECT
NAZEV, MESTO, KOLEJ, NASTUPISTE, PRIJEZD, ODJEZD FROM
SPOJ JOIN
ZASTAVKA ON
(ID_SPOJ = 3) AND
(ID_SPOJ = SPOJ_ID_SPOJ)
JOIN
STANICE ON
(STANICE_ID_STANICE = ID_STANICE);
SELECT
NAZEV, MESTO, KOLEJ, NASTUPISTE, PRIJEZD, ODJEZD FROM
SPOJ, ZASTAVKA, STANICE
WHERE
(SPOJ.ID_SPOJ = 3) AND
(SPOJ.ID_SPOJ = ZASTAVKA.SPOJ_ID_SPOJ)
AND
(ZASTAVKA.STANICE_ID_STANICE = STANICE.ID_STANICE);
SELECT
PORADI, KURACKY, KAPACITA, DRUH, HMOTNOST FROM
RAZENI R JOIN
VAGON V ON
(R.VUZ_ID_VUZ = V.VUZ_ID_VUZ)
JOIN
TYP_VAGON ON
(TYP_V_TYP_VUZ_ID_TYP_VUZ = TYP_VUZ_ID_TYP_VUZ)
JOIN
TYP_VUZ ON
(TYP_VUZ_ID_TYP_VUZ = ID_TYP_VUZ)
WHERE
SPOJ_ID_SPOJ = 1
ORDER
BY
PORADI;
SELECT
ID_SPOJ, ODJEZD_SPOJ, PRIJEZD_SPOJ FROM
SPOJ JOIN
PRACOVNIK ON
(RIZENI_PRACOVNIK_RC = RC)
WHERE
JMENO = 'Rumcajs';
SELECT
ID_SPOJ, ODJEZD_SPOJ, PRIJEZD_SPOJ FROM
SPOJ JOIN
PRACOVNIK ON
(POSUN_PRACOVNIK_RC = RC)
WHERE
JMENO = 'Marsal Russworm';
SELECT
15 AS
DOTAZ#_1, VYHYBKA.* FROM
(SELECT
* FROM
PRACOVNIK WHERE
JMENO = 'Rakosnicek')
JOIN
ZAMESTNANI ON
(RC = PRACOVNIK_RC)
JOIN
PRACOVISTE ON
(PRACOVISTE_ID_PRACOVISTE = ID_PRACOVISTE)
JOIN
VYHYBKA ON
(ID_PRACOVISTE = UMISTENI_V_ID_PRACOVISTE);
SELECT
A.NAZEV, B.NAZEV, KILOMETRY FROM
STANICE A JOIN
TRASA ON
(A.UMISTENI_S_ID_LOKACE = ZACATEK_ID_LOKACE)
JOIN
STANICE B ON
(KONEC_ID_LOKACE = B.UMISTENI_S_ID_LOKACE)
WHERE
(A.NAZEV like '%Praha%') AND
(B.NAZEV like '%Plzen%');
ALTER
session set NLS_DATE_FORMAT = 'DD.MM.YYYY';
SELECT
* FROM
VUZ WHERE
(POSLEDNI_SERVIS < '01.01.2004') AND
(DOMA_LOKALNI_SERVIS = 1) AND
(DOMOV_ID_STANICE = 1);
SELECT
Distinct
PRACOVNIK_RC FROM
OBECNY NATURAL
JOIN
ZAMESTNANI
WHERE
(SKUPINA_Z_POPIS = 'SERVISNI TECHNICI' AND
PRACOVISTE_ID_PRACOVISTE = 1);
SELECT
Distinct
JMENO, PRACOVNIK_RC FROM
PRACOVNIK JOIN
OBECNY ON
(RC = PRACOVNIK_RC)
NATURAL
JOIN
ZAMESTNANI
WHERE
(SKUPINA_Z_POPIS = 'SERVISNI TECHNICI' AND
PRACOVISTE_ID_PRACOVISTE = 1);
SELECT
20 AS
DOTAZ#_1, KOLEJ, NASTUPISTE, ZASTAVKA.PRIJEZD, ZASTAVKA.ODJEZD, OSOBNI_NAKLADNI FROM
(SELECT
ID_STANICE FROM
STANICE WHERE
NAZEV = 'Dobrany')
JOIN
ZASTAVKA ON
(ID_STANICE = STANICE_ID_STANICE)
JOIN
SPOJ ON
(SPOJ_ID_SPOJ = ID_SPOJ);
SELECT
Distinct
PRACOVISTE_ID_PRACOVISTE, SMEROVKA FROM
PRACOVNIK JOIN
ZAMESTNANI ON
(RC = PRACOVNIK_RC)
JOIN
PRACOVISTE ON
(PRACOVISTE_ID_PRACOVISTE = ID_PRACOVISTE)
WHERE
JMENO = 'Rakosnicek';
ALTER
session set NLS_DATE_FORMAT = 'hh24:mi';
SELECT
Distinct
PRACOVISTE_ID_PRACOVISTE, OD, DO FROM
PRACOVNIK JOIN
ZAMESTNANI ON
(RC = PRACOVNIK_RC)
JOIN
SMENA ON
(SMENA_CISLO_SMENY = CISLO_SMENY)
WHERE
JMENO = 'Rakosnicek';
ALTER
session set NLS_DATE_FORMAT = 'DD.MM.YYYY';
SELECT
1 AS
DOTAZ#_2, STANICE.NAZEV, VUZ.* FROM
VUZ JOIN
STANICE ON
(VUZ.DOMOV_ID_STANICE = STANICE.ID_STANICE)
WHERE
STANICE.NAZEV like '%Plzen%';
ALTER
session set NLS_DATE_FORMAT = 'DD.MM.YYYY';
SELECT
STANICE.NAZEV, VUZ.*, LOKOMOTIVA.* FROM
LOKOMOTIVA JOIN
VUZ ON
(LOKOMOTIVA.VUZ_ID_VUZ = VUZ.ID_VUZ)
JOIN
STANICE ON
(VUZ.DOMOV_ID_STANICE = STANICE.ID_STANICE)
WHERE
NAZEV like '%Praha%';
SELECT
ID_STANICE, NAZEV FROM
STANICE S1
WHERE
(SELECT
COUNT
(*) FROM
VUZ
JOIN
STANICE S2 ON
(DOMOV_ID_STANICE = S2.ID_STANICE)
WHERE
S1.ID_STANICE = S2.ID_STANICE) > 3;
ALTER
session set NLS_DATE_FORMAT = 'DD.MM.YYYY';
SELECT
* FROM
(SELECT
ID_STANICE, NAZEV FROM
STANICE S1
WHERE
(SELECT
COUNT
(*) FROM
VUZ JOIN
STANICE S2 ON
(DOMOV_ID_STANICE = S2.ID_STANICE)
WHERE
S1.ID_STANICE = S2.ID_STANICE) > 3)
JOIN
VUZ ON
(ID_STANICE = DOMOV_ID_STANICE);
ALTER
session set NLS_DATE_FORMAT = 'hh24:mi';
SELECT
5 AS
DOTAZ#_2, MESTO, NAZEV, KOLEJ, PRIJEZD, ODJEZD, (ODJEZD-PRIJEZD)*1440 AS
STANI, ID_SPOJ FROM
SPOJ JOIN
ZASTAVKA ON
(ID_SPOJ = SPOJ_ID_SPOJ)
JOIN
STANICE ON
(ID_STANICE = STANICE_ID_STANICE)
WHERE
ID_SPOJ = 2;
ALTER
session set NLS_DATE_FORMAT = 'hh24:mi';
SELECT
MESTO, NAZEV, KOLEJ, PRIJEZD, ODJEZD, (ODJEZD-PRIJEZD)*1440 AS
STANI, ID_SPOJ FROM
SPOJ JOIN
ZASTAVKA ON
(ID_SPOJ = SPOJ_ID_SPOJ)
JOIN
STANICE ON
(ID_STANICE = STANICE_ID_STANICE)
WHERE
NAZEV = 'Praha-Smichov';
SELECT
JMENO, PRIJEZD, ODJEZD, NAZEV, ID_SPOJ FROM
PRACOVNIK JOIN
STROJVUDCE ON
(RC = PRACOVNIK_RC)
JOIN
SPOJ ON
(RC = RIZENI_PRACOVNIK_RC)
JOIN
ZASTAVKA ON
(ID_SPOJ = SPOJ_ID_SPOJ)
JOIN
STANICE ON
(ID_STANICE = STANICE_ID_STANICE)
WHERE
STANICE.NAZEV like '%Praha-S%' ORDER
BY
ZASTAVKA.PRIJEZD;
SELECT
Z1.SPOJ_ID_SPOJ AS
SPOJ1, Z2.SPOJ_ID_SPOJ AS
SPOJ2 FROM
ZASTAVKA Z1 JOIN
ZASTAVKA Z2 ON
(Z1.STANICE_ID_STANICE = Z2.STANICE_ID_STANICE)
WHERE
(Z1.SPOJ_ID_SPOJ < Z2.SPOJ_ID_SPOJ) AND
(Z1.ODJEZD > Z2.PRIJEZD) AND
(Z2.ODJEZD > Z1.PRIJEZD);
SELECT
ST.NAZEV AS
NADRAZI, SP1.ID_SPOJ AS
SPOJ1, Z1.PRIJEZD AS
PRIJEZD1, Z1.ODJEZD AS
ODJEZD1, Z1.KOLEJ AS
KOLEJ1, PR1.JMENO AS
RIDIC1,
SP2.ID_SPOJ AS
SPOJ2, Z2.PRIJEZD AS
PRIJEZD2, Z2.ODJEZD AS
ODJEZD2, Z2.KOLEJ AS
KOLEJ2, PR2.JMENO AS
RIDIC2 FROM
ZASTAVKA Z1 JOIN
ZASTAVKA Z2 ON
(Z1.STANICE_ID_STANICE = Z2.STANICE_ID_STANICE)
JOIN
STANICE ST ON
(ST.ID_STANICE = Z1.STANICE_ID_STANICE )
JOIN
SPOJ SP1 ON
(SP1.ID_SPOJ = Z1.SPOJ_ID_SPOJ)
JOIN
PRACOVNIK PR1 ON
(SP1.RIZENI_PRACOVNIK_RC = PR1.RC)
JOIN
SPOJ SP2 ON
(SP2.ID_SPOJ = Z2.SPOJ_ID_SPOJ)
JOIN
PRACOVNIK PR2 ON
(SP2.RIZENI_PRACOVNIK_RC = PR2.RC)
WHERE
(Z1.SPOJ_ID_SPOJ != Z2.SPOJ_ID_SPOJ) AND
(Z1.ODJEZD > Z2.PRIJEZD) AND
(Z1.PRIJEZD < Z2.ODJEZD);
SELECT
10 AS
DOTAZ#_2, NAZEV, SMEROVKA, JMENO, OD, DO FROM
ZAMESTNANI JOIN
PRACOVNIK ON
(RC = PRACOVNIK_RC)
JOIN
PRACOVISTE ON
(ID_PRACOVISTE = PRACOVISTE_ID_PRACOVISTE)
JOIN
STANICE ON
(ID_STANICE = UMISTENI_P_ID_STANICE)
JOIN
SMENA ON
(SMENA_CISLO_SMENY = CISLO_SMENY);
SELECT
RIZENI_PRACOVNIK_RC, ID_TYP_VUZ FROM
SPOJ JOIN
POHON ON
(ID_SPOJ = SPOJ_ID_SPOJ)
JOIN
VUZ ON
(LOKOMOTIVA_VUZ_ID_VUZ = ID_VUZ)
JOIN
LOKOMOTIVA ON
(ID_VUZ = VUZ_ID_VUZ)
JOIN
TYP_VUZ ON
(TYP_L_TYP_VUZ_ID_TYP_VUZ = ID_TYP_VUZ);
SELECT
* FROM
OPRAVNENI
MINUS
SELECT
ID_TYP_VUZ AS
K_RIZENI_TYP_VUZ_ID_TYP_VUZ, RIZENI_PRACOVNIK_RC AS
OPRAVNEN_PRACOVNIK_RC FROM
SPOJ JOIN
POHON ON
(ID_SPOJ = SPOJ_ID_SPOJ)
JOIN
VUZ ON
(LOKOMOTIVA_VUZ_ID_VUZ = ID_VUZ)
JOIN
LOKOMOTIVA ON
(ID_VUZ = VUZ_ID_VUZ)
JOIN
TYP_VUZ ON
(TYP_L_TYP_VUZ_ID_TYP_VUZ = ID_TYP_VUZ);
SELECT
S0.NAZEV AS
SMER_Z, S1.NAZEV AS
SMER_1, S2.NAZEV AS
SMER_2, MECHANICKA, SMEROVKA FROM
VYHYBKA JOIN
PRACOVISTE ON
(UMISTENI_V_ID_PRACOVISTE = ID_PRACOVISTE)
JOIN
STANICE S0 ON
(UMISTENI_P_ID_STANICE = S0.ID_STANICE)
JOIN
STANICE S1 ON
(SMER_1_ID_STANICE = S1.ID_STANICE)
JOIN
STANICE S2 ON
(SMER_2_ID_STANICE = S2.ID_STANICE);
SELECT
PRACOVNIK.JMENO AS
PRODEJCE, X.NAZEV AS
Z, Y.NAZEV AS
DO, DETSKA, OSOBY, ZPATECNI, CENA FROM
JIZDENKA JOIN
STANICE X ON
(JIZDENKA.START_ID_STANICE = X.ID_STANICE)
JOIN
STANICE Y ON
(JIZDENKA.CIL_ID_STANICE = Y.ID_STANICE)
JOIN
PRACOVNIK ON
(JIZDENKA.VYDEJ_KYM_PRACOVNIK_RC = PRACOVNIK.RC)
ORDER
BY
CENA;
SELECT
1 AS
DOTAZ#_3, VAGON.* FROM
VAGON
MINUS
SELECT
1 AS
DOTAZ#_3, VAGON.* FROM
VAGON JOIN
RAZENI ON
(VAGON.VUZ_ID_VUZ = RAZENI.VUZ_ID_VUZ);
SELECT
Distinct
ID_SPOJ FROM
SPOJ
MINUS
SELECT
SPOJ_ID_SPOJ AS
ID_SPOJ FROM
VUZ JOIN
RAZENI ON
(ID_VUZ = VUZ_ID_VUZ)
WHERE
VUZ.DOMA_LOKALNI_SERVIS = 0;
SELECT
STANICE.* FROM
STANICE JOIN
PRACOVISTE ON
(UMISTENI_P_ID_STANICE = ID_STANICE)
JOIN
VYHYBKA ON
(UMISTENI_V_ID_PRACOVISTE = ID_PRACOVISTE)
MINUS
SELECT
STANICE.* FROM
(SELECT
UMISTENI_V_ID_PRACOVISTE FROM
VYHYBKA WHERE
MECHANICKA = 0)
JOIN
PRACOVISTE ON
(UMISTENI_V_ID_PRACOVISTE = ID_PRACOVISTE)
JOIN
STANICE ON
(UMISTENI_P_ID_STANICE = ID_STANICE);
SELECT
AVG
(CNT) FROM
(SELECT
SPOJ_ID_SPOJ, COUNT
(SPOJ_ID_SPOJ) AS
CNT FROM
RAZENI
GROUP
BY
SPOJ_ID_SPOJ);
SELECT
5 AS
DOTAZ#_3, STANICE.* FROM
STANICE
WHERE
ELEKTRIFIKACE = 1
MINUS
SELECT
5 AS
DOTAZ#_3, STANICE.* FROM
(SELECT
SPOJ_ID_SPOJ FROM
RAZENI
GROUP
BY
SPOJ_ID_SPOJ
HAVING
( COUNT
(1) > (SELECT
AVG
(CNT) FROM
(SELECT
SPOJ_ID_SPOJ, COUNT
(SPOJ_ID_SPOJ) AS
CNT FROM
RAZENI GROUP
BY
SPOJ_ID_SPOJ)
))
)
NATURAL
JOIN
ZASTAVKA
JOIN
STANICE ON
(STANICE_ID_STANICE = ID_STANICE);
SELECT
NAZEV, coalesce(CNT, 0) AS
POCET_VYDANYCH FROM
(SELECT
NAZEV, CNT FROM
STANICE,
(SELECT
VYDEJ_KDE_ID_STANICE, COUNT
(*) AS
CNT FROM
JIZDENKA
GROUP
BY
VYDEJ_KDE_ID_STANICE)
WHERE
STANICE.ID_STANICE = VYDEJ_KDE_ID_STANICE (+))
ORDER
BY
POCET_VYDANYCH DESC
;
SELECT
* FROM
SPOJ WHERE
JEDE_SOBOTA = 1
UNION
SELECT
* FROM
SPOJ WHERE
JEDE_NEDELE = 1;
SELECT
* FROM
STANICE WHERE
ELEKTRIFIKACE = 1
intersect
SELECT
* FROM
STANICE WHERE
HALA = 1;