/* 1. feladat */
SELECT rendszam, tipus FROM auto WHERE kategoria = 'Kisautó';

/* 2. feladat */
SELECT nev, szul_ev FROM ugyfel ORDER BY szul_ev DESC;

/* 3. feladat */
SELECT DISTINCT varos FROM ugyfel;

/* 4. feladat */
SELECT * FROM auto WHERE napidij BETWEEN 10000 AND 15000;

/* 5. feladat */
SELECT nev FROM ugyfel WHERE nev LIKE 'Kovács%' OR nev LIKE 'Nagy%';

/* 6. feladat */
SELECT CONCAT(marka, ' ', tipus) AS megnevezes FROM auto;

/* 7. feladat */
SELECT COUNT(*) FROM auto WHERE marka = 'Ford';

/* 8. feladat */
SELECT AVG(napidij) FROM auto WHERE kategoria = 'Luxus';

/* 9. feladat */
SELECT * FROM kolcsonzes WHERE YEAR(elvitel) = 2023 AND MONTH(elvitel) = 3;

/* 10. feladat */
SELECT DISTINCT nev FROM ugyfel, kolcsonzes WHERE ugyfel.id = kolcsonzes.ugyfel_id AND varos = 'Budapest';

/* 11. feladat */
SELECT rendszam FROM auto, ugyfel, kolcsonzes WHERE auto.id = auto_id AND ugyfel.id = ugyfel_id AND nev = 'Kiss Péter';

/* 12. feladat */
SELECT elvitel, visszahozatal FROM kolcsonzes WHERE DATEDIFF(visszahozatal, elvitel) > 5;

/* 13. feladat */
SELECT varos, COUNT(*) FROM ugyfel, kolcsonzes WHERE ugyfel.id = ugyfel_id GROUP BY varos;

/* 14. feladat */
SELECT kategoria, COUNT(*) FROM auto GROUP BY kategoria ORDER BY 2 DESC;

/* 15. feladat */
SELECT kolcsonzes.id, IF(DATEDIFF(visszahozatal, elvitel) * napidij > 100000, 'Magas', 'Normál') FROM kolcsonzes, auto WHERE kolcsonzes.auto_id = auto.id;

/* 16. feladat */
SELECT rendszam FROM auto WHERE napidij = (SELECT MAX(napidij) FROM auto);

/* 17. feladat */
SELECT nev FROM ugyfel WHERE id NOT IN (SELECT ugyfel_id FROM kolcsonzes);

/* 18. feladat */
SELECT rendszam FROM auto, kolcsonzes WHERE auto.id = auto_id GROUP BY auto.id HAVING COUNT(*) > (SELECT AVG(db) FROM (SELECT COUNT(*) AS db FROM kolcsonzes GROUP BY auto_id) AS tabla);

/* 19. feladat */
SELECT AVG(db) FROM (SELECT COUNT(*) AS db FROM kolcsonzes GROUP BY ugyfel_id) AS stat;

/* 20. feladat */
SELECT u1.nev, u2.nev, u1.varos FROM ugyfel u1, ugyfel u2 WHERE u1.varos = u2.varos AND u1.id < u2.id;