mysql> select id_vodica, meno_vodica, priezvisko_vodica, id_sk, id_nehod from Vodic;
+-----------+-------------+-------------------+-------+----------+
| id_vodica | meno_vodica | priezvisko_vodica | id_sk | id_nehod |
+-----------+-------------+-------------------+-------+----------+
| V1 | Ján | Modrý | S7 | N1 |
| V10 | Peter | Tkáč | S9 | N2 |
| V11 | Ján | Hrubý | S8 | N1 |
| V12 | Jozef | Petrák | S9 | N2 |
| V13 | Martin | Kotora | S5 | N1 |
| V14 | Ivan | Mačura | S6 | N1 |
| V15 | Peter | Mokrý | S7 | N1 |
| V16 | Pavol | Priekopník | S5 | N1 |
| V17 | Marek | Fedor | S7 | N1 |
| V2 | Michal | Lisí | S6 | N1 |
| V3 | Martin | Vylevý | S2 | N1 |
| V4 | Peter | Csont | S3 | N1 |
| V5 | Oliver | Habur | S5 | N1 |
| V6 | Patrik | Derečík | S5 | N1 |
| V7 | Tomáš | Petrík | S5 | N1 |
| V8 | Marek | Dinka | S1 | N1 |
| V9 | Lukáš | Lomnický | S8 | N2 |
+-----------+-------------+-------------------+-------+----------+
mysql> select id_autobus, typ_autobusu from Autobus where spotreba_100km=22;
+------------+--------------------+
| id_autobus | typ_autobusu |
+------------+--------------------+
| A0001 | ZHONG TONG - 6107H |
| A0004 | ZHONG TONG - 6110H |
| A0005 | ZHONG TONG - 6111H |
| B0001 | DAEWOO - 6119 |
| B0003 | DAEWOO - 6117 |
| B0005 | DAEWOO - 6115 |
+------------+--------------------+
mysql> select id_linka, nazov_linky from cestovna_linka where miesto_prijazdu = 'Bratislava';
+----------+-------------+
| id_linka | nazov_linky |
+----------+-------------+
| CS0005 | SlaBa1 |
| CS0006 | SlaBa2 |
| CS0007 | SlaBa3 |
| CS0008 | SlaBa4 |
| CS0012 | DsBa1 |
| CS0013 | DsBa2 |
| CS0014 | DsBa3 |
| CS0017 | ScBa1 |
| CS0018 | ScBa2 |
| CS0021 | StBa1 |
| CS0022 | StBa1 |
+----------+-------------+
mysql> select dat_uskutocnenia as datum, sum(spotreba_paliva) as spotreba_paliva from uskutocnenie_linky where dat_uskutocnenia=20090921;
+------------+-----------------+
| datum | spotreba_paliva |
+------------+-----------------+
| 2009-09-21 | 92 |
+------------+-----------------+
Výpis informácií o usporiadaní podľa množstva prepravených cestujúcich
(na jednotlivých linkách, jednotlivými vodičmi)
select uskutocnenie_linky.pocet_prepravenych, Vodic.priezvisko_vodica, Vodic.id_sk as skusenost, cestovna_linka.nazov_linky from uskutocnenie_linky, Vodic, cestovna_linka where uskutocnenie_linky.id_vodica=Vodic.id_vodica and uskutocnenie_linky.id_linka=cestovna_linka.id_linka order by (pocet_prepravenych);
+--------------------+-------------------+-----------+-------------+
| pocet_prepravenych | priezvisko_vodica | skusenost | nazov_linky |
+--------------------+-------------------+-----------+-------------+
| 11 | Csont | S3 | BaSla4 |
| 18 | Lomnický | S8 | BaDs1 |
| 18 | Derečík | S5 | SlaBa2 |
| 20 | Vylevý | S2 | BaSla3 |
| 21 | Hrubý | S8 | BaDs3 |
| 24 | Petrík | S5 | SlaBa3 |
| 25 | Modrý | S7 | BaSla1 |
| 28 | Tkáč | S9 | BaDs2 |
| 30 | Dinka | S1 | SlaBa4 |
| 32 | Lisí | S6 | BaSla2 |
| 35 | Habur | S5 | SlaBa1 |
| 37 | Kotora | S5 | DsBa2 |
| 40 | Petrák | S9 | DsBa1 |
| 42 | Mačura | S6 | DsBa3 |
| 43 | Mokrý | S7 | BaSc1 |
+--------------------+-------------------+-----------+-------------+
+------------------+-------------+------------+----------+---------------------+
| dat_uskutocnenia | nazov_linky | poc_cestuj | cen_list | prijmy_z_cestovneho |
+------------------+-------------+------------+----------+---------------------+
| 2009-09-21 | BaSla1 | 25 | 2.15 | 53.7500023841858 |
| 2009-09-21 | SlaBa3 | 24 | 2.15 | 51.6000022888184 |
| 2009-09-21 | SlaBa1 | 35 | 2.15 | 75.2500033378601 |
| 2009-09-21 | BaSla2 | 32 | 2.15 | 68.8000030517578 |
| 2009-09-21 | DsBa2 | 37 | 2.3 | 85.0999982357025 |
| 2009-09-21 | BaDs1 | 18 | 2.3 | 41.3999991416931 |
| 2009-09-21 | BaDs3 | 21 | 2.3 | 48.299998998642 |
| 2009-09-22 | DsBa1 | 40 | 2.3 | 91.9999980926514 |
| 2009-09-22 | BaSla3 | 20 | 2.15 | 43.0000019073486 |
| 2009-09-22 | BaSla4 | 11 | 2.15 | 23.6500010490417 |
| 2009-09-22 | BaSc1 | 43 | 1.35 | 58.0500010251999 |
| 2009-09-22 | BaDs2 | 28 | 2.3 | 64.399998664856 |
| 2009-09-22 | DsBa3 | 42 | 2.3 | 96.5999979972839 |
| 2009-09-25 | SlaBa2 | 18 | 2.15 | 38.7000017166138 |
| 2009-09-25 | SlaBa4 | 30 | 2.15 | 64.5000028610229 |
+------------------+-------------+------------+----------+---------------------+
select *from naklady_pohonne_hmoty
+------------------+-------------+------------------+
| dat_uskutocnenia | nazov_linky | naklady |
+------------------+-------------+------------------+
| 2009-09-21 | BaSla1 | 13.2000002861023 |
| 2009-09-21 | SlaBa3 | 13.2000002861023 |
| 2009-09-21 | SlaBa1 | 14.3000003099442 |
| 2009-09-21 | BaSla2 | 14.3000003099442 |
| 2009-09-21 | DsBa2 | 16.5000003576279 |
| 2009-09-21 | BaDs1 | 15.400000333786 |
| 2009-09-21 | BaDs3 | 14.3000003099442 |
| 2009-09-22 | DsBa1 | 17.4400005340576 |
| 2009-09-22 | BaSla3 | 11.9900003671646 |
| 2009-09-22 | BaSla4 | 11.9900003671646 |
| 2009-09-22 | BaSc1 | 14.1700004339218 |
| 2009-09-22 | BaDs2 | 15.2600004673004 |
| 2009-09-22 | DsBa3 | 18.5300005674362 |
| 2009-09-25 | SlaBa2 | 10.8000004291534 |
| 2009-09-25 | SlaBa4 | 14.0400005578995 |
+------------------+-------------+------------------+
select AVG(naklady) from naklady_pohonne_hmoty;
+------------------+
| AVG(naklady) |
+------------------+
| 14.3613337278366 |
+------------------+
create view prijem as select uskutocnenie_linky.dat_uskutocnenia, cestovna_linka.nazov_linky, uskutocnenie_linky.pocet_prepravenych*cestovna_linka.cena_listka as prijmy from uskutocnenie_linky, cestovna_linka where uskutocnenie_linky.id_linka=cestovna_linka.id_linka order by (dat_uskutocnenia);
| dat_uskutocnenia | nazov_linky | prijmy |
+------------------+-------------+------------------+
| 2009-09-21 | BaSla1 | 53.7500023841858 |
| 2009-09-21 | SlaBa3 | 51.6000022888184 |
| 2009-09-21 | SlaBa1 | 75.2500033378601 |
| 2009-09-21 | BaSla2 | 68.8000030517578 |
| 2009-09-21 | DsBa2 | 85.0999982357025 |
| 2009-09-21 | BaDs1 | 41.3999991416931 |
| 2009-09-21 | BaDs3 | 48.299998998642 |
| 2009-09-22 | DsBa1 | 91.9999980926514 |
| 2009-09-22 | BaSla3 | 43.0000019073486 |
| 2009-09-22 | BaSla4 | 23.6500010490417 |
| 2009-09-22 | BaSc1 | 58.0500010251999 |
| 2009-09-22 | BaDs2 | 64.399998664856 |
| 2009-09-22 | DsBa3 | 96.5999979972839 |
| 2009-09-25 | SlaBa2 | 38.7000017166138 |
| 2009-09-25 | SlaBa4 | 64.5000028610229 |
+------------------+-------------+------------------+
create view ziskovost as select cestovna_linka.nazov_linky, uskutocnenie_linky.dat_uskutocnenia, (uskutocnenie_linky.pocet_prepravenych*cestovna_linka.cena_listka)-(uskutocnenie_linky.spotreba_paliva*uskutocnenie_linky.cena_naft) as zisk_strata from uskutocnenie_linky, cestovna_linka where uskutocnenie_linky.id_linka=cestovna_linka.id_linka order by (dat_uskutocnenia);
+-------------+------------------+------------------+
| nazov_linky | dat_uskutocnenia | zisk_strata |
+-------------+------------------+------------------+
| BaSla1 | 2009-09-21 | 40.5500020980835 |
| SlaBa3 | 2009-09-21 | 38.4000020027161 |
| SlaBa1 | 2009-09-21 | 60.950003027916 |
| BaSla2 | 2009-09-21 | 54.5000027418137 |
| DsBa2 | 2009-09-21 | 68.5999978780746 |
| BaDs1 | 2009-09-21 | 25.9999988079071 |
| BaDs3 | 2009-09-21 | 33.9999986886978 |
| DsBa1 | 2009-09-22 | 74.5599975585938 |
| BaSla3 | 2009-09-22 | 31.010001540184 |
| BaSla4 | 2009-09-22 | 11.6600006818771 |
| BaSc1 | 2009-09-22 | 43.8800005912781 |
| BaDs2 | 2009-09-22 | 49.1399981975555 |
| DsBa3 | 2009-09-22 | 78.0699974298477 |
| SlaBa2 | 2009-09-25 | 27.9000012874603 |
| SlaBa4 | 2009-09-25 | 50.4600023031235 |
+-------------+------------------+------------------+
select AVG(zisk) from ziskovost;
+------------------+
| AVG(zisk_strata) |
+------------------+
| 45.9786669890086 |
+------------------+
+------------------+
| sum(zisk_strata) |
+------------------+
| 689.680004835129 |
+------------------+
select uskutocnenie_linky.dat_uskutocnenia, cestovna_linka.nazov_linky, uskutocnenie_linky.pocet_prepravenych from uskutocnenie_linky, cestovna_linka where uskutocnenie_linky.id_linka=cestovna_linka.id_linka and pocet_prepravenych<'20' order by (dat_uskutocnenia);
+------------------+-------------+--------------------+
| dat_uskutocnenia | nazov_linky | pocet_prepravenych |
+------------------+-------------+--------------------+
| 2009-09-21 | BaDs1 | 18 |
| 2009-09-22 | BaSla4 | 11 |
| 2009-09-25 | SlaBa2 | 18 |
+------------------+-------------+--------------------+
select uskutocnenie_linky.dat_uskutocnenia, uskutocnenie_linky.pocet_prepravenych, vodic.priezvisko_vodica, cestovna_linka.nazov_linky from uskutocnenie_linky, vodic, cestovna_linka where uskutocnenie_linky.id_vodica=vodic.id_vodica and uskutocnenie_linky.id_linka=cestovna_linka.id_linka and uskutocnenie_linky.pocet_prepravenych=(select max(pocet_prepravenych) from uskutocnenie_linky);
+------------------+--------------------+-------------------+-------------+
| dat_uskutocnenia | pocet_prepravenych | priezvisko_vodica | nazov_linky |
+------------------+--------------------+-------------------+-------------+
| 2009-09-22 | 43 | Mokrý | BaSc1 |
+------------------+--------------------+-------------------+-------------+
select typ_autobusu, spotreba_100km, pocet_miest from autobus where typ_autobusu like '%ZHONG%';
+--------------------+----------------+-------------+
| typ_autobusu | spotreba_100km | pocet_miest |
+--------------------+----------------+-------------+
| ZHONG TONG - 6107H | 22 | 43 |
| ZHONG TONG - 6108H | 21 | 43 |
| ZHONG TONG - 6109H | 21 | 43 |
| ZHONG TONG - 6110H | 22 | 43 |
| ZHONG TONG - 6111H | 22 | 43 |
| ZHONG TONG - 6112H | 21 | 43 |
+--------------------+----------------+-------------+