1. feladat:
SELECT Count(terulet.azon) - 1 FROM terulet;
vagy
SELECT Count(terulet.azon) FROM terulet
WHERE terulet.nev != "Budapest";

2. feladat:
SELECT terulet.nev, regio.nev FROM terulet
INNER JOIN regio ON terulet.regioazon = regio.azon
INNER JOIN nagyregio ON regio.nagyazon = nagyregio.azon
WHERE nagyregio.nev = "Dunántúl";

3. feladat:
SELECT kabel.lakas FROM kabel
INNER JOIN terulet ON kabel.terazon = terulet.azon
WHERE terulet.nev = "Budapest" AND kabel.ev = 2012;

4. feladat:
SELECT kabel2014 - kabel2004 
FROM
	(SELECT kabel.lakas AS kabel2004 FROM kabel
	INNER JOIN terulet ON kabel.terazon = terulet.azon
	WHERE terulet.nev = "Tolna" AND kabel.ev = 2004) AS al2004
JOIN
	(SELECT kabel.lakas AS kabel2014 FROM kabel
	INNER JOIN terulet ON kabel.terazon = terulet.azon
	WHERE terulet.nev = "Tolna" AND kabel.ev = 2014) AS al2014;

5. feladat:
SELECT terulet.nev, kabel.lakas FROM kabel
INNER JOIN terulet ON kabel.terazon = terulet.azon
WHERE kabel.ev = 2015 AND terulet.nev != "Budapest"
ORDER BY kabel.lakas DESC
LIMIT 3;

6. feladat:
SELECT kabel.ev FROM kabel
INNER JOIN terulet ON kabel.terazon = terulet.azon
WHERE terulet.nev = "Nógrád" AND kabel.lakas > 40000
ORDER BY kabel.ev ASC
LIMIT 1;
vagy
SELECT MIN(kabel.ev) FROM kabel
INNER JOIN terulet ON kabel.terazon = terulet.azon
WHERE terulet.nev = "Nógrád" AND kabel.lakas > 40000;

7. feladat:
SELECT kabel.ev, terulet.nev, kabel.lakas FROM kabel
INNER JOIN terulet ON kabel.terazon = terulet.azon
INNER JOIN regio ON terulet.regioazon = regio.azon
INNER JOIN nagyregio ON regio.nagyazon = nagyregio.azon
WHERE nagyregio.nev = "Alföld és Észak" 
AND kabel.ev IN (2004, 2008, 2012, 2016)
ORDER BY kabel.ev ASC, terulet.nev ASC;

8. feladat:
SELECT heves, heveslakas, masik, masiklakas, masikev FROM
(SELECT terulet.nev AS heves, kabel.lakas AS heveslakas, kabel.ev AS hevesev, regio.nev AS hevesregio FROM kabel
INNER JOIN terulet ON kabel.terazon = terulet.azon
INNER JOIN regio ON terulet.regioazon = regio.azon
WHERE terulet.nev = "Heves") AS alheves
INNER JOIN
(SELECT terulet.nev AS masik, kabel.lakas AS masiklakas, kabel.ev AS masikev, regio.nev AS masikregio FROM kabel
INNER JOIN terulet ON kabel.terazon = terulet.azon
INNER JOIN regio ON terulet.regioazon = regio.azon) AS almasik
ON hevesev = masikev AND hevesregio = masikregio AND masiklakas > heveslakas
ORDER BY masikev ASC;

