Verified Commit 5667af72 authored by Benedikt's avatar Benedikt
Browse files

loesungen als html Kommentar

parent 2998381f
Loading
Loading
Loading
Loading
+519 −0
Original line number Diff line number Diff line
@@ -19,6 +19,12 @@ kapitel: [4]
- [**00**] - Zeigen Sie **alle Spalten** und **alle Zeilen** aus der Tabelle `customer`.

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        *
    FROM customer
    ;
    -->
    ```sql-output
    +-------------+----------+------------+-----------+-------------------------------------+------------+--------+---------------------+---------------------+
    | customer_id | store_id | first_name | last_name | email                               | address_id | active | create_date         | last_update         |
@@ -36,6 +42,14 @@ kapitel: [4]
- [**01**] - Zeigen Sie nur die Spalten `first_name`, `last_name` und `email` aus der Tabelle `customer`.

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        first_name,
        last_name,
        email
    FROM customer
    ;
    -->
    ```sql-output
    +------------+-----------+-------------------------------------+
    | first_name | last_name | email                               |
@@ -57,6 +71,14 @@ kapitel: [4]
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        first_name AS Vorname,
        last_name AS Nachname,
        email
    FROM customer
    ;
    -->
    ```sql-output
    +----------+----------+-------------------------------------+
    | Vorname  | Nachname | email                               |
@@ -78,6 +100,15 @@ kapitel: [4]
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        first_name AS Vorname,
        last_name AS Nachname,
        email
    FROM customer
    LIMIT 5
    ;
    -->
    ```sql-output
    +-----------+----------+-------------------------------------+
    | Vorname   | Nachname | email                               |
@@ -103,6 +134,13 @@ kapitel: [4]
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        first_name
    FROM actor
    ORDER BY first_name
    ;
    -->
    ```sql-output
    +-------------+
    | first_name  |
@@ -134,6 +172,13 @@ kapitel: [4]
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT DISTINCT
        first_name
    FROM actor
    ORDER BY first_name
    ;
    -->
    ```sql-output
    +-------------+
    | first_name  |
@@ -169,6 +214,14 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**06**] - Finden Sie alle Filme (Tabelle `film`) mit Länge (length) > 150 Minuten. Zeigen Sie nur die Spalten `title` und `length`.

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        title AS Titel,
        length AS Länge
    FROM film
    WHERE length > 150
    ;
    -->
    ```sql-output
    +-------------------------+--------+
    | Titel                   | Länge  |
@@ -203,6 +256,14 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**07**] - Finden Sie alle Filme, deren Mietdauer (rental_duration) genau 5 Tage beträgt. Zeigen Sie nur die Spalten `title` und `rental_duration`.

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        title AS Filmtitel,
        rental_duration AS Mietdauer
    FROM film
    WHERE rental_duration = 5
    ;
    -->
    ```sql-output
    +-------------------------+-----------+
    | Filmtitel               | Mietdauer |
@@ -231,6 +292,16 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**08**] - Finden Sie alle Filme mit Mietpreis (rental_rate) <= 2.99 **und** Mietdauer von genau 6 Tagen. Zeigen Sie nur die Spalten `title`, `rental_rate` und `rental_duration`.

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        title AS Filmtitel,
        rental_rate AS Mietpreis,
        rental_duration AS Mietdauer
    FROM film
    WHERE rental_rate <= 2.99
        AND rental_duration = 6
    ;
    -->
    ```sql-output
    +-------------------------+-----------+-----------+
    | Filmtitel               | Mietpreis | Mietdauer |
@@ -264,6 +335,15 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**09**] - Welche Schauspieler haben den Vornamen 'Tom'?

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        actor_id,
        first_name,
        last_name
    FROM actor
    WHERE first_name = "Tom"
    ;
    -->
    ```sql-output
    +----------+------------+-----------+
    | actor_id | first_name | last_name |
@@ -280,6 +360,15 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**10**] - Welche Schauspieler haben den Nachnamen 'Johansson'?

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        actor_id,
        first_name,
        last_name
    FROM actor
    WHERE last_name = "Johansson"
    ;
    -->
    ```sql-output
    +----------+------------+-----------+
    | actor_id | first_name | last_name |
@@ -297,6 +386,15 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**11**] - Welche Schauspieler haben einen Nachnamen, der an der 2. Stelle ein 'i' hat?

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        actor_id,
        first_name,
        last_name
    FROM actor
    WHERE last_name LIKE "_i%"
    ;
    -->
    ```sql-output
    +----------+------------+-------------+
    | actor_id | first_name | last_name   |
@@ -339,6 +437,15 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        actor_id,
        first_name,
        last_name
    FROM actor
    WHERE first_name LIKE "A%a"
    ;
    -->
    ```sql-output
    +----------+------------+-------------+
    | actor_id | first_name | last_name   |
@@ -356,6 +463,16 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**13**] - Welche Schauspieler haben einen Nachnamen, der genau 5 Zeichen lang ist?

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        actor_id,
        first_name,
        last_name
    FROM actor
    WHERE last_name LIKE "_____"
    # WHERE LENGTH(last_name) = 5
    ;
    -->
    ```sql-output
    +----------+-------------+-----------+
    | actor_id | first_name  | last_name |
@@ -414,6 +531,16 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        actor_id,
        first_name,
        last_name,
        LENGTH(last_name) AS Länge
    FROM actor
    WHERE LENGTH(last_name) = LENGTH(first_name)
    ;
    -->
    ```sql-output
    +----------+------------+-----------+--------+
    | actor_id | first_name | last_name | Länge  |
@@ -455,6 +582,15 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**15**] - Finden Sie alle Filme, deren Beschreibung (film.description) den Teilstring "**database**" enthält.

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        film_id,
        title,
        description
    FROM film
    WHERE description LIKE "%database%"
    ;
    -->
    ```sql-output
    +---------+---------------------+------------------------------------------------------------------------------------------------------------------------------------+
    | film_id | title               | description                                                                                                                        |
@@ -485,6 +621,12 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**16**] - Wie viele Filme sind in der Datenbank gespeichert?

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        COUNT(*) AS num_films
    FROM film
    ;
    -->
    ```sql-output
    +-----------+
    | num_films |
@@ -500,6 +642,12 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**17**] - Wie viele Schauspieler gibt es insgesamt?

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        COUNT(*) AS num_actors
    FROM actor
    ;
    -->
    ```sql-output
    +------------+
    | num_actors |
@@ -520,6 +668,12 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        COUNT(DISTINCT last_name) AS distinct_actor_names
    FROM actor
    ;
    -->
    ```sql-output
    +----------------------+
    | distinct_actor_names |
@@ -535,6 +689,12 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**19**] - Wie viele verschiedene Filmbewertungen (film.rating) gibt es?

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        COUNT(DISTINCT rating) AS distinct_film_ratings
    FROM film
    ;
    -->
    ```sql-output
    +------------------------+
    | disctinct_film_ratings |
@@ -550,6 +710,12 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**20**] - Wie ist die durchschnittliche Laufzeit (film.length) aller Filme?
   
    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        AVG(length) AS avg_film_length
    FROM film
    ;
    -->
    ```sql-output
    +-----------------+
    | avg_film_length |
@@ -565,6 +731,12 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**21**] - Finden Sie den kleinsten Mietpreis (film.rental_rate) aller Filme.
   
    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        MIN(rental_rate) AS min_rental_rate
    FROM film
    ;
    -->
    ```sql-output
    +-----------------+
    | min_rental_rate |
@@ -580,6 +752,12 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**22**] - Finden Sie die maximale Mietdauer (film.rental_duration) aller Filme.

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        MAX(rental_duration) AS max_rental_days
    FROM film
    ;
    -->
    ```sql-output
    +-----------------+
    | max_rental_days |
@@ -599,6 +777,12 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        COUNT(*) AS num_payments
    FROM payment
    ;
    -->
    ```sql-output
    +--------------+
    | num_payments |
@@ -614,6 +798,12 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**24**] - Summieren Sie die Beträge (payment.amount) aller Zahlungen.

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        SUM(amount) AS sum_payments
    FROM payment
    ;
    -->
    ```sql-output
    +--------------+
    | sum_payments |
@@ -629,6 +819,14 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**25**] - Finden Sie den kleinsten, größten und den durchschnittlichen Betrag (payment.amount) aller Zahlungen.

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        MIN(amount) AS min,
        MAX(amount) AS max,
        AVG(amount) AS avg
    FROM payment
    ;
    -->
    ```sql-output
    +------+-------+----------+
    | min  | max   | avg      |
@@ -646,6 +844,14 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**26**] - Wie viele Filme gibt es pro Altersfreigabe (film.rating)?
   
    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        rating,
        COUNT(*) AS film_count
    FROM film
    GROUP BY rating
    ;
    -->
    ```sql-output
    +--------+------------+
    | rating | film_count |
@@ -661,9 +867,18 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}
    <hr>


- [**27**] - Wie hoch ist die durchschnittliche Mietdauer (film.rental_duration) pro Altersfreigabe (film.rating)?
   
    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        rating,
        AVG(rental_duration) AS avg_rental_duration
    FROM film
    GROUP BY rating
    ;
    -->
    ```sql-output
    +--------+---------------------+
    | rating | avg_rental_duration |
@@ -679,9 +894,19 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}
    <hr>


- [**28**] - Wie ist die durchschnittliche Laufzeit (film.length) der Filme, gruppiert nach Altersfreigabe (film.rating)?
   
    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        rating,
        AVG(length) AS avg_length
    FROM film
    GROUP BY rating
    ORDER BY avg_length
    ;
    -->
    ```sql-output
    +--------+------------+
    | rating | avg_length |
@@ -701,6 +926,16 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
- [**29**] - Finden Sie den kleinsten, größten und den durchschnittlichen Betrag (payment.amount) aller Zahlungen **pro** Kunde (payment.customer_id).

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        customer_id,
        MIN(amount) AS min,
        MAX(amount) AS max,
        AVG(amount) AS avg
    FROM payment
    GROUP BY customer_id
    ;
    -->
    ```sql-output
    +-------------+------+-------+----------+
    | customer_id | min  | max   | avg      |
@@ -736,6 +971,16 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}
   
    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        rating,
        COUNT(*) AS film_count
    FROM film
    GROUP BY rating
    ORDER BY film_count DESC
    LIMIT 1
    ;
    -->
    ```sql-output
    +--------+------------+
    | rating | film_count |
@@ -758,6 +1003,23 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        c.customer_id,
        c.first_name,
        c.last_name,
        a.address,
        a.district,
        a.postal_code,
        ct.city,
        ctr.country
    FROM customer c
        JOIN address a ON a.address_id = c.address_id
        JOIN city ct ON ct.city_id = a.city_id
        JOIN country ctr ON ctr.country_id = ct.country_id
    ORDER BY c.customer_id
    ;
    -->
    ```sql-output
    +-------------+-------------+--------------+-------------------------------------+----------------------+-------------+-----------------+-----------------+
    | customer_id | first_name  | last_name    | address                             | district             | postal_code | city            | country         |
@@ -797,6 +1059,20 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        c.customer_id,
        c.first_name,
        c.last_name,
        ctr.country
    FROM customer c
        JOIN address a ON a.address_id = c.address_id
        JOIN city ct ON ct.city_id = a.city_id
        JOIN country ctr ON ctr.country_id = ct.country_id
    WHERE ctr.country LIKE "Germany"
    ORDER BY c.customer_id
    ;
    -->
    ```sql-output
    +-------------+------------+------------+---------+
    | customer_id | first_name | last_name  | country |
@@ -822,6 +1098,17 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}
   
    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        a.actor_id,
        a.first_name,
        a.last_name
    FROM actor a
        JOIN film_actor fa ON fa.actor_id = a.actor_id
        JOIN film f ON f.film_id = fa.film_id
    WHERE title LIKE "Academy Dinosaur"
    ;
    -->
    ```sql-output
    +----------+------------+-----------+
    | actor_id | first_name | last_name |
@@ -850,6 +1137,19 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        c.customer_id,
        c.first_name,
        c.last_name
    FROM film f
        JOIN inventory i ON i.film_id = f.film_id
        JOIN rental r ON r.inventory_id = i.inventory_id
        JOIN customer c ON c.customer_id = r.customer_id
    WHERE f.title LIKE "Academy Dinosaur"
    ORDER BY c.customer_id
    ;
    -->
    ```sql-output
    +-------------+------------+-------------+
    | customer_id | first_name | last_name   |
@@ -891,6 +1191,16 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        ctr.country_id,
        ctr.country,
        COUNT(*) AS num_cities
    FROM city c
        JOIN country ctr ON ctr.country_id = c.country_id
    GROUP BY ctr.country_id
    ;
    -->
    ```sql-output
    +------------+---------------------------------------+------------+
    | country_id | country                               | num_cities |
@@ -1019,6 +1329,17 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        a.actor_id,
        a.first_name,
        a.last_name,
        COUNT(*) AS film_count
    FROM actor a
        JOIN film_actor fa ON fa.actor_id = a.actor_id
    GROUP BY a.actor_id
    ;
    -->
    ```sql-output
    +----------+-------------+--------------+------------+
    | actor_id | first_name  | last_name    | film_count |
@@ -1058,6 +1379,16 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        c.name AS Film_Kategorie,
        COUNT(*) AS Anzahl_Filme
    FROM film_category fc
        JOIN category c ON fc.category_id = c.category_id
    GROUP BY fc.category_id
    ORDER BY Anzahl_Filme DESC
    ;
    -->
    ```sql-output
    +----------------+--------------+
    | Film_Kategorie | Anzahl_Filme |
@@ -1092,6 +1423,20 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        cat.category_id,
        cat.`name`,
        COUNT(*) AS num_rentals
    FROM rental r
        JOIN inventory i ON i.inventory_id = r.inventory_id
        JOIN film_category fc ON fc.film_id = i.film_id
        JOIN category cat ON cat.category_id = fc.category_id
    GROUP BY cat.category_id, cat.`name`
    ORDER BY num_rentals DESC
    LIMIT 3
    ;
    -->
    ```sql-output
    +-------------+-----------+-------------+
    | category_id | name      | num_rentals |
@@ -1113,6 +1458,20 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        cat.category_id,
        cat.`name`,
        COUNT(*) AS num_rentals
    FROM rental r
        JOIN inventory i ON i.inventory_id = r.inventory_id
        JOIN film_category fc ON fc.film_id = i.film_id
        JOIN category cat ON cat.category_id = fc.category_id
    GROUP BY cat.category_id, cat.`name`
    ORDER BY num_rentals ASC
    LIMIT 3
    ;
    -->
    ```sql-output
    +-------------+--------+-------------+
    | category_id | name   | num_rentals |
@@ -1134,6 +1493,22 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        c.customer_id,
        c.first_name,
        c.last_name,
        COUNT(*) AS num_rentals
    FROM rental r
        JOIN customer c ON c.customer_id = r.customer_id
    GROUP BY
        c.customer_id,
        c.first_name,
        c.last_name
    HAVING num_rentals > 30
    ORDER BY num_rentals DESC
    ;
    -->
    ```sql-output
    +-------------+-------------+--------------+-------------+
    | customer_id | first_name  | last_name    | num_rentals |
@@ -1173,6 +1548,22 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        c.customer_id,
        c.first_name,
        c.last_name,
        COUNT(*) AS Ausgeliehene_Filme
    FROM customer c
        JOIN address a ON a.address_id = c.address_id
        JOIN city ct ON ct.city_id = a.city_id
        JOIN country ctr ON ctr.country_id = ct.country_id
        JOIN rental r ON r.customer_id = c.customer_id
    WHERE ctr.country LIKE "Germany"
    GROUP BY c.customer_id
    ORDER BY c.customer_id
    ;
    -->
    ```sql-output
    +-------------+------------+------------+--------------------+
    | customer_id | first_name | last_name  | Ausgeliehene_Filme |
@@ -1198,6 +1589,22 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        c.customer_id,
        c.first_name,
        c.last_name,
        SUM(amount) AS Ausleih_Gebühren
    FROM customer c
        JOIN address a ON a.address_id = c.address_id
        JOIN city ct ON ct.city_id = a.city_id
        JOIN country ctr ON ctr.country_id = ct.country_id
        JOIN payment p ON p.customer_id = c.customer_id
    WHERE ctr.country LIKE "Germany"
    GROUP BY c.customer_id
    ORDER BY c.customer_id
    ;
    -->
    ```sql-output
    +-------------+------------+------------+-------------------+
    | customer_id | first_name | last_name  | Ausleih_Gebühren  |
@@ -1223,6 +1630,24 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        ca.name AS Kategorie,
        COUNT(*) AS Häufigkeit
    FROM customer c
        JOIN address a ON a.address_id = c.address_id
        JOIN city ct ON ct.city_id = a.city_id
        JOIN country ctr ON ctr.country_id = ct.country_id
        JOIN rental r ON r.customer_id = c.customer_id
        JOIN inventory i ON i.inventory_id = r.inventory_id
        JOIN film_category fc ON fc.film_id = i.film_id
        JOIN category ca ON ca.category_id = fc.category_id
    WHERE ctr.country LIKE "Germany"
    GROUP BY ca.name
    ORDER BY Häufigkeit DESC
    LIMIT 1
    ;
    -->
    ```sql-output
    +-----------+-------------+
    | Kategorie | Häufigkeit  |
@@ -1242,6 +1667,19 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        c.customer_id,
        c.first_name,
        c.last_name,
        SUM(amount) AS bisher_bezahlt
    FROM customer c
        JOIN payment p ON p.customer_id = c.customer_id
    GROUP BY c.customer_id
    ORDER BY bisher_bezahlt DESC
    LIMIT 3
    ;
    -->
    ```sql-output
    +-------------+------------+-----------+----------------+
    | customer_id | first_name | last_name | bisher_bezahlt |
@@ -1263,6 +1701,21 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT DISTINCT
        f.film_id,
	    f.title
    FROM customer c
        JOIN address a ON a.address_id = c.address_id
        JOIN city ct ON ct.city_id = a.city_id
        JOIN country ctr ON ctr.country_id = ct.country_id
        JOIN rental r ON r.customer_id = c.customer_id
        JOIN inventory i ON i.inventory_id = r.inventory_id
        JOIN film f ON f.film_id = i.film_id
    WHERE ctr.country LIKE "Germany"
    ORDER BY f.film_id
    ;
    -->
    ```sql-output
    +---------+-------------------------+
    | film_id | title                   |
@@ -1302,6 +1755,18 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        ctr.country AS Land,
        COUNT(*) AS Anzahl_Kunden
    FROM customer c
        JOIN address a ON a.address_id = c.address_id
        JOIN city ct ON ct.city_id = a.city_id
        JOIN country ctr ON ctr.country_id = ct.country_id
    GROUP BY Land
    ORDER BY Anzahl_Kunden DESC
    ;
    -->
    ```sql-output
    +---------------------------------------+---------------+
    | Land                                  | Anzahl_Kunden |
@@ -1428,6 +1893,19 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        ctr.country AS Land,
        COUNT(*) AS Anzahl_Kunden
    FROM customer c
        JOIN address a ON a.address_id = c.address_id
        JOIN city ct ON ct.city_id = a.city_id
        JOIN country ctr ON ctr.country_id = ct.country_id
    GROUP BY Land
    HAVING Anzahl_Kunden > 9
    ORDER BY Anzahl_Kunden DESC
    ;
    -->
    ```sql-output
    +--------------------+---------------+
    | Land               | Anzahl_Kunden |
@@ -1460,6 +1938,17 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        ctr.country_id,
        ctr.country
    FROM customer c
        JOIN address a ON a.address_id = c.address_id
        JOIN city ct ON ct.city_id = a.city_id
        RIGHT JOIN country ctr ON ctr.country_id = ct.country_id
    WHERE c.customer_id IS NULL
    ;
    -->
    ```sql-output
    +------------+-----------+
    | country_id | country   |
@@ -1479,6 +1968,18 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        ct.city_id,
        ct.city,
        ctr.country
    FROM customer c
        JOIN address a ON a.address_id = c.address_id
        RIGHT JOIN city ct ON ct.city_id = a.city_id
        JOIN country ctr ON ctr.country_id = ct.country_id
    WHERE c.customer_id IS NULL
    ;
    -->
    ```sql-output
    +---------+------------+-----------+
    | city_id | city       | country   |
@@ -1501,6 +2002,24 @@ Mit der [WHERE](https://www.w3schools.com/mysql/mysql_where.asp){target="_blank"
    {% endhint %}

    {% hint "Ergebnis", "success" %}
    <!--
    SELECT
        customer_id,
        first_name,
        last_name
    FROM customer
    WHERE customer_id NOT IN (
        SELECT DISTINCT
            c.customer_id
        FROM rental r
            JOIN inventory i ON i.inventory_id = r.inventory_id
            JOIN film_category fc ON fc.film_id = i.film_id
            JOIN category cat ON cat.category_id = fc.category_id
            JOIN customer c ON c.customer_id = r.customer_id
        WHERE cat.`name` = "Horror"
    )
    ;
    -->
    ```sql-output
    +-------------+-------------+-------------+
    | customer_id | first_name  | last_name   |