-- 1 -----------------------------------------
SELECT jmeno
FROM vyrobek
WHERE
	vID IN 
	(
		SELECT vID
		FROM koupil
		WHERE login = 'vinetu'
	)
	AND	vID IN 
	(
		SELECT vID
		FROM koupil
		WHERE login = 'pepik'
	)

-- 2 -----------------------------------------
SELECT jmeno
FROM vyrobek
WHERE
	vID NOT IN 
	(
		SELECT vID
		FROM koupil
	)

-- 3 -----------------------------------------
SELECT jmeno
FROM vyrobek
WHERE
	vID IN 
	(
		SELECT vID
		FROM koupil
		WHERE login = 'vinetu'
	)
	AND vID NOT IN 
	(
		SELECT vID
		FROM koupil
		WHERE login = 'pepik'
	)

-- 4 -----------------------------------------
SELECT DISTINCT vyrobek.jmeno
FROM vyrobek, koupil k1
WHERE
	vyrobek.vID = k1.vID AND EXISTS
	(
		SELECT *
		FROM koupil k2
		WHERE k1.vID = k2.vID AND k1.login = k2.login AND k1.rok != k2.rok
	)

-- 5 -----------------------------------------
SELECT jmeno
FROM vyrobek
WHERE
	aktualni_cena > ALL
	(
		SELECT cena
		FROM koupil
		WHERE koupil.vID = vyrobek.vID
	)

-- 6 -----------------------------------------
SELECT DISTINCT login
FROM koupil k1
WHERE
	NOT EXISTS
	(
		SELECT *
		FROM koupil k2
		WHERE k1.login = k2.login AND (k1.vID != k2.vID OR k1.rok != k2.rok)
	)

-- 7 -----------------------------------------
SELECT DISTINCT login
FROM koupil k1
WHERE
	NOT EXISTS
	(
		SELECT *
		FROM koupil k2
		WHERE k1.login = k2.login AND k1.vID != k2.vID 
	)

-- 8 -----------------------------------------
SELECT DISTINCT jmeno
FROM koupil k1, vyrobek
WHERE
	k1.vID = vyrobek.vID AND
	NOT EXISTS
	(
		SELECT *
		FROM koupil k2
		WHERE k1.login = k2.login AND k1.vID != k2.vID 
	)
	
-- 9 -----------------------------------------
SELECT DISTINCT login
FROM koupil k1
WHERE
	NOT EXISTS
	(
		SELECT *
		FROM koupil k2
		WHERE k1.vID = k2.vID AND k1.cena > k2.cena
	)