Backend/20250312/mozi2.sql
2025-03-19 09:08:40 +01:00

57 lines
1.4 KiB
SQL

CREATE DATABASE mozi2
DEFAULT CHARACTER SET utf8
COLLATE utf8_hungarian_ci;
-- 15
SELECT COUNT(id) as "vetitesek_szama"
FROM vetites
WHERE kezdes = '20:00';
-- 16
SELECT COUNT(jegy.id) as "jegy_db", vendeg.nev
as "vendeg_nev"
FROM jegy
INNER JOIN vendeg on jegy.vendegId = vendeg.id
GROUP BY (jegy.vendegId)
ORDER BY jegy_db DESC LIMIT 5;
-- 17
UPDATE film
SET cim = 'Csillagok között'
WHERE cim = 'Interstellar';
-- 18
INSERT INTO filmtipus (nev)
VALUES ('Animációs');
-- 19
SELECT nev as "nev", count(jegy.id) as
'teljes_aru_jegy_db'
FROM vendeg
INNER JOIN jegy on vendeg.id =
jegy.vendegId
WHERE nev = 'Fodor András'
and kedvezmeny = 0;
-- 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 film
INNER JOIN vetites on film.id = vetites.filmId
INNER JOIN jegy on vetites.id = jegy.vetitesId
GROUP BY film.cim
ORDER BY teljes_bevetel DESC LIMIT 1;
-- felhasználó
CREATE USER 'felhasznalo'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT ON mozi2.filmtipus TO 'felhasznalo'@'localhost';
GRANT SELECT ON mozi2.vendeg TO 'felhasznalo'@'localhost';
GRANT SELECT ON mozi2.jegy TO 'felhasznalo'@'localhost';
GRANT SELECT ON mozi2.film TO 'felhasznalo'@'localhost';
GRANT SELECT ON mozi2.vetites TO 'felhasznalo'@'localhost';
GRANT UPDATE ON mozi2.film TO 'felhasznalo'@'localhost';
FLUSH PRIVILEGES;