Navigation auf uzh.ch

Suche

Department of Informatics Database Technology

Database Lab: SQL Exercises

SQL-Aufgaben / SQL Exercises

This document lists the SQL exercises. Each exercise has additional information:

  • hint: for many queries, a hint is provided. Move the mouse over the lightbulb, and the hint should pop up. Of course, the less hints you need, the better.
  • difficulty: The other information shows the difficulty of the exercise (ona scale from 1 to 5). Again, move over the image and the difficulty rating should pop up. The more plus-signs you see, the more difficult the exercise.

SQL Exercises

  1. alle Mitglieder
    all members
    difficulty
  2. alle Fahrzeuge
    all vehicles
    difficulty
  3. Aktuelles Datum und Uhrzeit
    current date and time
    hint, difficulty
  4. die Namen aller Personen
    the names of all persons
    hint, difficulty
  5. die Namen aller persoenlichen Mitglieder
    the names of all person members
    hint, difficulty
  6. die Namen und Heimatstationen der persoenlichen Mitglieder, sortiert nach Station
    the names and home location of the person members, in the order of the home locations
    hint, difficulty
  7. die Namen und Heimatstation der Genossenschaftsmitglieder, sortiert nach Namen der Heimatstation
    names and home locations of the coop members sorted by home location name
    hint, difficulty
  8. die Namen der persoenlichen Mitglieder zusammen mit der Angabe, ob sie bereits einen Unfall hatten
    the names of the person members plus the indication if the members have had an accident
    difficulty
  9. die Namen der persoenlichen Mitglieder zusammen mit der Angabe, ob sie bereits einen Unfall hatten (schoen formattiert)
    the names of the person members plus the indication if the members have had an accident (nicely formattted)
    hint, difficulty
  10. welche Mitglieder hatten bereits einen Unfall?
    which person members have had an accident?
    hint, difficulty
  11. die Mitgliedsnummern und Jahresgebuehren der persoenlichen Mitglieder
    the member numbers and yearly fees of the person members
    hint, difficulty
  12. die Mitgliedsnummern und Jahresgebuehren der Firmenmitglieder
    the member numbers and yearly fees of the company members
    hint, difficulty
  13. die Mitgliedsnummern und Jahresgebuehren der Genossenschaftsmitglieder
    the member numbers and yearly fees of the coop members
    hint, difficulty
  14. die Mitgliedsnummern und Jahresgebuehren aller Mitglieder
    the member numbers and yearly fees of all members
    hint, difficulty
  15. die Kennzeichen, Marken und Modelle aller Fahrzeuge
    the licenseplate, make, and model of all vehicles
    difficulty
  16. die Marken und Modelle der Fahrzeuge mit Heimatstation
    Make, model, and name of the home location of the vehicles
    hint, difficulty
  17. die Marken und Modelle der Fahrzeuge mit Heimatstation. Auch die Fahrzeuge ohne Heimatstation sollen angezeigt werden.
    Make, model, and name of the home location of the vehicles. The make and model of vehicles without home location should be shown as well
    hint, difficulty
  18. die Marken und Modelle der Fahrzeuge mit Heimatstation. Auch die Fahrzeuge ohne Heimatstation und die Stationen ohne Fahrzeuge sollen angezeigt werden.
    Make, model, and name of the home location of the vehicles. The make and model of vehicles without home location as well as the locations without vehicles should be shown as well
    hint, difficulty
  19. Fahrzeuge ohne Heimatstation
    Vehicles without a home location
    hint, difficulty
  20. Stationen ohne Fahrzeuge
    Locations without vehicles
    hint, difficulty
  21. die Kuerzel, Namen und Addressen der Stationen
    short name, long name, and address of the locations
    difficulty
  22. die Kuerzel, Namen und Orte der Stationen
    short name, long name, and city of the locations
    hint, difficulty
  23. die Reservationen des Fahrzeugs 'ZH-1020'
    the reservation of vehicle 'ZH-1020'
    hint, difficulty
  24. die Reservationen des Mitglieds mit der Nummer 1000
    the reservations of the member with member number 1000
    hint, difficulty
  25. die offenen Reservationen des Mitglieds mit der Nummer 1000
    open reservations of the member number 1000
    hint, difficulty
  26. alle Reservation, die noch nicht in Rechnung gestellt wurden
    all reservations that have not yet been billed
    difficulty
  27. alle Benutzer, die fern der Heimat reserviert haben (Fahrzeugstandort ungleich Heimatstandort des Benutzers)
    all members who have reserved a vehicle at a location other than their home location
    difficulty
  28. alle Benutzer, die fern der Heimat reserviert haben (Fahrzeugstandort ungleich Heimatstandort des Benutzers), obwohl es den Fahrzeugtyp an der Heimatstation gibt
    all members who have reserved a vehicle at a location other than their home location even though the vehicle type exists at their home location
    hint, difficulty
  29. alle Benutzer, die fern der Heimat reserviert haben (Fahrzeugstandort ungleich Heimatstandort des Benutzers), obwohl es den Fahrzeugtyp an der Heimatstation gibt und eines der Fahrzeuge des gewuenschten Typs frei war/wäre.
    all members who have reserved a vehicle at a location other than their home location even though the vehicle type exists at their home location and a vehicle of the desired time would be free during the interval in question
    hint, difficulty
  30. die Rechnungen des Mitglieds mit der Nummer 1000
    the invoices for member number 1000
    difficulty
  31. die Kennzeichen der Fahrzeuge der Benutzungen
    the license plates of the vehicles who have been used (not only reserved)
    difficulty
  32. die den einzelnen Benutzungen zugrundeliegenden Kilometerpreise
    the correct price per kilometer for each use
    hint, difficulty
  33. Entfernungsbasierte Kosten der Benutzungen
    the distance-based prices for the vehicle uses
    hint, difficulty
  34. Die Summe der Benutzungsdauern pro Tag
    the sum (of hours) of vehicle uses per day
    hint, difficulty
  35. Die durchschnittliche Benutzungsdauer
    The average duration of vehicle use
    difficulty
  36. die kürzeste Entfernung, die während einer Benutzung zurückgelegt wurde
    The shortest distance (in kilometers) driven in a single vehicle use
    difficulty
  37. die durchschnittliche Entfernung pro Benutzung
    the average distance driven per vehicle use
    difficulty
  38. die Summe der Entfernungen, die pro Fahrzeug zurückgelegt wurde
    the sum of distances driven per vehicle
    hint, difficulty
  39. die durchschnittliche Entfernungen, die pro Fahrzeug zurückgelegt wurde (in allen Reservationen)
    the average distance driven per vehicle (in all reservations)
    hint, difficulty
  40. Die Stationen, die Anzahl der gemieteten Parkplätze und die monatliche Mietgebühr
    The locations, the number of leased parking spaces and the monthly lease (for the parking spaces)
    difficulty
  41. Parkplatzmiete (pro Parkplatz) pro Station
    locations and the parking space lease per parking space
    difficulty
  42. Anzahl freie Parkplaetze pro Station
    number of free parking spaces per location
    hint, difficulty
  43. Gesamtkosten aller Parkplaetze
    total sum of parking space lease (across all locations)
    hint, difficulty
  44. alle Rechnungen
    all invoices
    difficulty
  45. alle offenen Rechnungen
    all open invoices (unpaid)
    difficulty
  46. alle ueberfaelligen Rechnungen
    all overdue invoices
    hint, difficulty
  47. alle saeumigen Mitglieder
    the members with due and open invoices
    difficulty
  48. alle saeumigen persoenlichen Mitglieder
    the person members with due and open invoices
    hint, difficulty
  49. die Namen der saeumigen persoenlichen Mitglieder
    the full names of person members with due and open invoices
    hint, difficulty
  50. die Namen der saeumigen persoenlichen Mitglieder (nun jedes Mitglied nur einmal !)
    the full names of person members with due and open invoices (make sure that each name appears only once)
    difficulty
  51. alle Fahrzeuge
    all vehicles
    difficulty
  52. alle Personenwagen
    all motor cars
    difficulty
  53. alle Limousinen
    all limousines
    difficulty
  54. alle Fahrzeuge in Zürich
    all vehicles whose home location is in the city of Zurich
    hint, difficulty
  55. alle persoenlichen Mitglieder, die in einem Ort wohnen, in dem es eine Station mit Limousinen gibt
    all person members living in a city with a location which has limousines
    hint, difficulty
  56. die Anzahl Limousinen pro Station
    the locations and number of limousines at each location
    difficulty
  57. die Reservationsen fuer Fahrzeuge beliebigen Typs an der station ust
    all reservations for vehicles of any category at the location ust
    difficulty
  58. die Reservationsen fuer Fahrzeuge beliebigen Typs an der station ust am 11.11.2014 von 9-10 Uhr
    all reservations for vehicles of any category at the location ust on 11.11.2015 at 9-10
    hint, difficulty
  59. alle Fahrzeuge beliebigen Typs, die am 11.11.2014 um 9:00 Uhr frei waren
    all vehicles which are free on 11.11.2015 at 9:00
    hint, difficulty
  60. alle Fahrzeuge beliebigen Typs an der Station ust, die am 11.11.2014 um 9:00 Uhr frei waren
    all vehicles at location ust which are free on 11.11.2015 at 9:00
    hint, difficulty
  61. alle PKWs mit Kindersitz an der Station grs, die am 11.11.2014 um 9:00 Uhr frei waren
    all motor cars with a child seat at location ust which are free on 11.11.2015 at 9:00
    hint, difficulty
  62. Kennzeichen mit der Angabe, ob das Fahrzeug am 09.09.2014 von 9-10 Uhr frei war
    all license plates together with the information whether the vehicle was free on 09.09.2015 from 9-10
    hint, difficulty
  63. die Kennzeichen der Fahrzeuge zusammen mit der Anzahl der Reservationen am 11.11.2014 von 9-10 Uhr
    all license plates with the number of reservations free on 09.09.2015 from 9-10
    hint, difficulty
  64. die Kuerzel der Stationen zusammen mit der Anzahl der Fahrzeuge, die am 11.11.2014 von 9-10 Uhr frei sind
    the short names of locations with the number of vehicles at each location which are free on 11.11.2014 from 9-10
    hint, difficulty
  65. Benutzer ohne Reservationen
    members without any reservations
    hint, difficulty
  66. die Kennzeichen und Anzahl der Reservationen der einzelnen Fahrzeuge
    the license plates and number of reservations of each vehicle
    hint, difficulty
  67. der hoechste Kilometerstand eines Fahrzeugs
    the maximum odometer value
    hint, difficulty
  68. das Fahrzeug mit dem hoechsten Kilometerstand
    the vehicle with the highest odometer value
    hint, difficulty
  69. der höchste Benzinverbrauch eines Fahrzeugs
    the highest fuel consumption of all vehicles
    hint, difficulty
  70. das Fahrzeug mit dem höchsten Benzinverbrauch
    the vehicle with the highest fuel consumption
    hint, difficulty
  71. die Anzahl Limousinen pro Station
    the number of limousines per location
    hint, difficulty
  72. die maximale Anzahl Limousinen an einer Station
    the highest number of limousines per location
    hint, difficulty
  73. Die Station mit der maximalen Anzahl Limos
    the location with the highest number of limousines
    hint, difficulty
  74. alle Stationen, die (ueber die Nachbarschaftsbeziehung) in maximal vier Schritten von Mönchaltorf (moe) erreichbar sind
    all locations that are reachable (via the nextLocation relationship) in no more than four steps from location moe
    hint, difficulty
  75. ein Belegungsplan fuer das Auto '194 SUA' fuer den 11.11. 2014 und die folgenden beiden Tage
    a free/busy plan for the vehicle '194 SUA' for 11.11. 2015 and the following two days
    hint, difficulty
  76. ein Belegungsplan fuer die Station Greifensee fuer den 11.11. 2014
    a free/busy plan for the location Greifensee for 11.11. 2015
    hint, difficulty
  77. die Kennzeichen und Anzahl der Reservationen der einzelnen Fahrzeuge, absteigend sortiert nach Anzahl der Reservationen, zusammen mit der kummulierten Summe der Reservationen und dem Anteil des Fahrzeugs an dieser kummulierten Summe (kummulierte Summe = Summe der Reservationen aller Fahrzeuge bis einschliesslich des aktuellen in der Liste)
    the license plates and number of reservations per vehicle. order should be by number of reservations (largest to smallest). Also compute the cummulated sum of the reservations and the contribution of the current vehicle to the cummulated sum
    hint, difficulty
  78. der durchschnittliche Spritverbrauch pro Fahrzeug
    the average fuel consumption (per 100km) per vehicle
    difficulty
  79. der maximale durchschnittliche Spritverbrauch pro Fahrzeug
    the highest average fuel consumption per vehicle
    hint, difficulty
  80. das Fahrzeug mit dem maximalen Spritverbrauch
    the vehicle with the highest average fuel consumption
    hint, difficulty
  81. der maximale, minimale und durchschnittliche Spritverbrauch pro Fahrzeugtyp
    the highest, average, and smallest average fuel consumption by vehicle category
    hint, difficulty
  82. maximaler Spritverbrauch pro Fahrzeug und Benutzer
    the highest fuel consumption by member and vehicle (for a single reservation)
    hint, difficulty
  83. der Benutzer und das Fahrzeug mit dem hoechsten Benzinverbrauch (für eine einzelne Benutzung)
    member and vehicle with the highest fuel consumption (for a single reservation)
    hint, difficulty
  84. das Fahrzeug mit dem maximalen Spritverbrauch
    the vehicle with the highest fuel consumption (NOT per kilometer)
    hint, difficulty
  85. Kategorien und der höchste Kilometerstand pro Kategorie
    Vehicle categories and the highest odometer value for each category
    hint, difficulty
  86. Kategorien und der höchste Kilometerstand pro Kategorie sowie das Kennzeichen des Fahrzeugs (dieser Kategorie) mit diesem Kilometerstand
    Vehicle categories and the highest odometer value for each category, plus the license plate of the vehicle with this odometer value
    hint, difficulty
  87. Die Benutzungsdauern der Reservationen
    the duration of the reservations
    hint, difficulty
  88. Die Benutzungsdauern der Reservationen (jeden Wert nur einmal)
    the duration of the reservations, list each value only once
    difficulty
  89. Die Benutzungsdauern der Reservationen (jeden Wert nur einmal), die längste Benutzung zuerst
    the duration of the reservations, list each value only once and sort from largest to smallest
    difficulty
  90. Ein Histogramm der Benutzungsdauern der Reservationen, d.h. zu jeder Dauer die Angabe, wie oft sie vorkommt
    a histogram of reservation durations, i.e., for each duration calculate how often it occurs
    difficulty
  91. Die Summe der Reservationen für alle Fahrzeuge ab dem 7.7.2015 für die nächsten 1000 Stunden
    The sum of reservation durations for all vehicles starting on 7.7.2015 for the next 1000 hours
    hint, difficulty
  92. Jahr und Monat der Reservationen (jede Kombination nur einmal)
    year and month of reservations (each combination only once)
    hint, difficulty
  93. Jahr und Monat der Reservationen und Anzahl der Reservationen in diesem Monat (ausschlaggebend ist der Reservationsbeginn)
    year and month of reservations and number of reservations during this month (use reservation begin)
    hint, difficulty
  94. Jahr und Monat der Reservationen und Summe der Reservationsdauern in diesem Monat (ausschlaggebend ist der Reservationsbeginn)
    year and month of reservations and sum of reservation durations during this month (use reservation begin)
    hint, difficulty
  95. Jahr und Monat der Reservationen und Anzahl der Reservationen in diesem Monat (ausschlaggebend ist der Reservationsbeginn); und Bildung einer Rangliste innerhalb der einzelnen Jahre
    year and month of reservations and number of reservations during this month (use reservation begin). Sort according to number of reservations within each year
    hint, difficulty
  96. gleich wie oben, Summe der Reservationsdauern anstatt Anzahl Reservationen
    same as above, but use sum of reservation durations instead of reservation count
    hint, difficulty
  97. Jahr und Monat der Reservationen und Summe der Reservationsdauern in diesem Monat (ausschlaggebend ist der Reservationsbeginn); und Bildung einer Rangliste innerhalb der einzelnen Jahre. Ausgabe der auf der Rangliste führenden beiden Monate
    same as above, but use sum of reservation durations instead of reservation count. Return only the first two months
    hint, difficulty
  98. gleitender 3-Monatsdurchschnitt der Reservationsanzahlen
    calculate the 3-months moving average of reservation counts
    hint, difficulty
  99. monatsweise kummulierte Summe der Reservationszahlen innerhalb eines Jahres
    calculate the cumulated sums of monthly reservation counts per year
    hint, difficulty
  100. Einteilung der Monate des Jahres 2014 in Tertile (drei Quantile) gemäss der Anzahl Reservationen
    assign the months of the year 2015 to tertiles (three quantiles) based on the number of reservations per month
    hint, difficulty

Weiterführende Informationen

Title

Teaser text