/*Feladat 13*/
CREATE DATABASE mozi CHARACTER SET = "utf8" COLLATE = "utf8_hungarian_ci";

/*Feladat 14*/

/*Feladat 15*/
SELECT * FROM vetites
WHERE kezdes LIKE "20:00:00";

/*Feladat 16*/
SELECT vendeg.nev AS `vendeg_nev`,
COUNT(jegy.id) AS `jegy_db` FROM jegy
INNER JOIN vendeg ON vendeg.id = jegy.vendegId
GROUP BY `vendeg_nev`
ORDER BY `jegy_db` DESC LIMIT 5;

/*Feladat 17*/
UPDATE film SET cim = "Csillagok között" WHERE cim = "Interstellar";

/*Feladat 18*/
INSERT INTO filmtipus(nev) VALUES("Animációs");

/*Feladat 19*/
SELECT vendeg.nev AS `nev`,
 COUNT(jegy.id) AS `teljes_aru_jegy_db` FROM jegy
INNER JOIN vendeg ON vendeg.id = jegy.vendegId
WHERE vendeg.nev LIKE "Fodor András"
AND jegy.kedvezmeny = 0;

/*Feladat 20*/

SELECT film.cim AS `film_neve`,
COUNT(jegy.id) AS `jegy_darabszam`,
SUM(film.jegyar - (film.jegyar * (jegy.kedvezmeny / 100))) AS `teljes_bevetel`
FROM vetites
INNER JOIN jegy ON  jegy.vetitesId = vetites.id
INNER JOIN film ON film.id = vetites.filmId
GROUP BY film.id
ORDER BY `teljes_bevetel` DESC LIMIT 1;
