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 text "hint" or the light bulb, if it is displayed, 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 (on a scale from 1 to 5). Again, move the cursor over the text "difficulty" or the tinguely machine 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. alle Personenwagen
    all motor cars
    difficulty

  4. alle Limousinen
    all limousines
    difficulty

  5. Aktuelles Datum und Uhrzeit
    current date and time
    hint difficulty

  6. die Namen aller Personen
    the names of all persons
    hint difficulty

  7. die Namen aller persoenlichen Mitglieder
    the names of all person members
    hint difficulty

  8. 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

  9. 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

  10. 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

  11. 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

  12. welche persoenlichen Mitglieder hatten bereits einen Unfall?
    which person members have had an accident?
    hint difficulty

  13. die Kennzeichen, Marken und Modelle aller Fahrzeuge
    the licenseplate, make, and model of all vehicles
    difficulty

  14. die Marken und Modelle der Fahrzeuge mit Heimatstation
    Make, model, and name of the home location of the vehicles
    hint difficulty

  15. 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

  16. 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

  17. Fahrzeuge ohne Heimatstation
    Vehicles without a home location
    hint difficulty

  18. Stationen ohne Fahrzeuge
    Locations without vehicles
    hint difficulty

  19. die Kuerzel, Namen und Addressen der Stationen
    short name, long name, and address of the locations
    difficulty

  20. die Kuerzel, Namen und Orte der Stationen
    short name, long name, and city of the locations
    hint difficulty

  21. die Reservationen des Fahrzeugs 'ZH-1020'
    the reservation of vehicle 'ZH-1020'
    hint difficulty

  22. die Reservationen des Mitglieds mit der Nummer 1000
    the reservations of the member with member number 1000
    hint difficulty

  23. die offenen Reservationen des Mitglieds mit der Nummer 1000
    open reservations of the member number 1000
    hint difficulty

  24. alle Reservationen, die noch nicht in Rechnung gestellt wurden
    all reservations that have not yet been billed
    hint difficulty

  25. die Rechnungen des Mitglieds mit der Nummer 1000
    the invoices for member number 1000
    difficulty

  26. die Kennzeichen der Fahrzeuge der Benutzungen
    the license plates of the vehicles who have been used (not only reserved)
    difficulty

  27. die den einzelnen Benutzungen zugrundeliegenden Kilometerpreise
    the correct price per kilometer for each use
    hint difficulty

  28. Entfernungsbasierte Kosten der Benutzungen
    the distance-based prices for the vehicle uses
    hint difficulty

  29. Die Summe der Benutzungsdauern pro Tag
    the sum (of hours) of vehicle uses per day
    hint difficulty

  30. Die durchschnittliche Benutzungsdauer
    The average duration of vehicle use
    difficulty

  31. die kürzeste Entfernung, die während einer Benutzung zurückgelegt wurde
    The shortest distance (in kilometers) driven in a single vehicle use
    difficulty

  32. die durchschnittliche Entfernung pro Benutzung
    the average distance driven per vehicle use
    difficulty

  33. die Summe der Entfernungen, die pro Fahrzeug zurückgelegt wurde
    the sum of distances driven per vehicle
    hint difficulty

  34. die durchschnittliche Entfernungen, die pro Fahrzeug zurückgelegt wurde (in allen Reservationen)
    the average distance driven per vehicle (in all reservations)
    hint difficulty

  35. die Mitgliedsnummern und Jahresgebuehren der persoenlichen Mitglieder
    the member numbers and yearly fees of the person members
    hint difficulty

  36. die Mitgliedsnummern und Jahresgebuehren der Firmenmitglieder
    the member numbers and yearly fees of the company members
    hint difficulty

  37. die Mitgliedsnummern und Jahresgebuehren der Genossenschaftsmitglieder
    the member numbers and yearly fees of the coop members
    hint difficulty

  38. die Mitgliedsnummern und Jahresgebuehren aller Mitglieder
    the member numbers and yearly fees of all members
    hint difficulty

  39. alle Rechnungen
    all invoices
    difficulty

  40. alle offenen Rechnungen
    all open invoices (unpaid)
    difficulty

  41. alle ueberfaelligen Rechnungen
    all overdue invoices
    hint difficulty

  42. alle saeumigen Mitglieder
    the members with due and open invoices
    difficulty

  43. alle saeumigen persoenlichen Mitglieder
    the person members with due and open invoices
    hint difficulty

  44. die Namen der saeumigen persoenlichen Mitglieder
    the full names of person members with due and open invoices
    hint difficulty

  45. 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

  46. alle Fahrzeuge in Zürich
    all vehicles whose home location is in the city of Zurich
    hint difficulty

  47. 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

  48. die Anzahl Limousinen pro Station
    the locations and number of limousines at each location
    difficulty

  49. die Reservationsen fuer Fahrzeuge beliebigen Typs an der station ust
    all reservations for vehicles of any category at the location ust
    difficulty

  50. die Reservationsen fuer Fahrzeuge beliebigen Typs an der station ust am 11.11.2017 von 9-10 Uhr
    all reservations for vehicles of any category at the location ust on 11.11.2017 at 9-10
    hint difficulty

  51. alle Fahrzeuge beliebigen Typs, die am 11.11.2017 um 9:00 Uhr frei waren
    all vehicles which are free on 11.11.2017 at 9:00
    hint difficulty

  52. alle Fahrzeuge beliebigen Typs an der Station ust, die am 11.11.2017 um 9:00 Uhr frei waren
    all vehicles at location ust which are free on 11.11.2017 at 9:00
    hint difficulty

  53. alle PKWs mit Kindersitz an der Station grs, die am 11.11.2017 um 9:00 Uhr frei waren
    all motor cars with a child seat at location ust which are free on 11.11.2017 at 9:00
    hint difficulty

  54. Kennzeichen mit der Angabe, ob das Fahrzeug am 09.09.2017 von 9-10 Uhr frei war
    all license plates together with the information whether the vehicle was free on 09.09.2017 from 9-10
    hint difficulty

  55. die Kennzeichen der Fahrzeuge zusammen mit der Anzahl der Reservationen am 11.11.2017 von 9-10 Uhr
    all license plates with the number of reservations free on 09.09.2017 from 9-10
    hint difficulty

  56. die Kuerzel der Stationen zusammen mit der Anzahl der Fahrzeuge, die am 11.11.2017 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.2017 from 9-10
    hint difficulty

  57. Benutzer ohne Reservationen
    members without any reservations
    hint difficulty

  58. die Kennzeichen und Anzahl der Reservationen der einzelnen Fahrzeuge
    the license plates and number of reservations of each vehicle
    hint difficulty

  59. der hoechste Kilometerstand eines Fahrzeugs
    the maximum odometer value
    hint difficulty

  60. das Fahrzeug mit dem hoechsten Kilometerstand
    the vehicle with the highest odometer value
    hint difficulty

  61. der höchste Benzinverbrauch eines Fahrzeugs
    the highest fuel consumption of all vehicles
    hint difficulty

  62. das Fahrzeug mit dem höchsten Benzinverbrauch
    the vehicle with the highest fuel consumption
    hint difficulty

  63. die Anzahl Limousinen pro Station
    the number of limousines per location
    hint difficulty

  64. die maximale Anzahl Limousinen an einer Station
    the highest number of limousines per location
    hint difficulty

  65. Die Station mit der maximalen Anzahl Limos
    the location with the highest number of limousines
    hint difficulty

  66. 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

  67. 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

  68. der durchschnittliche Spritverbrauch pro Fahrzeug
    the average fuel consumption (per 100km) per vehicle
    difficulty

  69. der maximale durchschnittliche Spritverbrauch pro Fahrzeug
    the highest average fuel consumption per vehicle
    hint difficulty

  70. das Fahrzeug mit dem maximalen Spritverbrauch
    the vehicle with the highest average fuel consumption
    hint difficulty

  71. der maximale, minimale und durchschnittliche Spritverbrauch pro Fahrzeugtyp
    the highest, average, and smallest average fuel consumption by vehicle category
    hint difficulty

  72. maximaler Spritverbrauch pro Fahrzeug und Benutzer
    the highest fuel consumption by member and vehicle (for a single reservation)
    hint difficulty

  73. 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

  74. das Fahrzeug mit dem maximalen Spritverbrauch
    the vehicle with the highest fuel consumption (NOT per kilometer)
    hint difficulty

  75. Kategorien und der höchste Kilometerstand pro Kategorie
    Vehicle categories and the highest odometer value for each category
    hint difficulty

  76. 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

  77. Die Benutzungsdauern der Reservationen
    the duration of the reservations
    hint difficulty

  78. Die Benutzungsdauern der Reservationen (jeden Wert nur einmal)
    the duration of the reservations, list each value only once
    difficulty

  79. 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

  80. 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

  81. Die Summe der Reservationen für alle Fahrzeuge ab dem 7.7.2017 für die nächsten 1000 Stunden
    The sum of reservation durations for all vehicles starting on 7.7.2017 for the next 1000 hours
    hint difficulty

  82. Jahr und Monat der Reservationen (jede Kombination nur einmal)
    year and month of reservations (each combination only once)
    hint difficulty

  83. 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

  84. 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

  85. 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

  86. gleich wie oben, Summe der Reservationsdauern anstatt Anzahl Reservationen
    same as above, but use sum of reservation durations instead of reservation count
    hint difficulty

  87. 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

  88. gleitender 3-Monatsdurchschnitt der Reservationsanzahlen
    calculate the 3-months moving average of reservation counts
    hint difficulty

  89. monatsweise kummulierte Summe der Reservationszahlen innerhalb eines Jahres
    calculate the cumulated sums of monthly reservation counts per year
    hint difficulty

  90. Einteilung der Monate des Jahres 2017 in Tertile (drei Quantile) gemäss der Anzahl Reservationen
    assign the months of the year 2017 to tertiles (three quantiles) based on the number of reservations per month
    hint difficulty

  91. Anzahl Reservationen gruppiert nach den Dimensionen Mitglied, Fahrzeug, Station
    The number of reservations grouped over the dimensions member, vehicle, and location
    hint difficulty

  92. Anzahl Reservationen gruppiert nach allen möglichen Kombinationen der Dimensionen Mitglied und Fahrzeugtyp
    The number of reservations grouped over all possible combinations of the dimensions member (member number) and vehicle type.
    hint difficulty

  93. Anzahl Reservationen gruppiert nach allen möglichen Kombinationen der Dimensionen Mitglied und Fahrzeugtyp, so dass auch Mitglieder und Fahrzeugtypen ohne Reservationen aufgeführt werden
    The number of reservations grouped over all possible combinations of the dimensions member (member number) and vehicle type such that also types and members without reservations are shown.
    hint difficulty

  94. Anzahl Reservationen gruppiert nach allen möglichen Kombinationen der Dimensionen Mitglied und Fahrzeugtyp, so dass auch Mitglieder und Fahrzeugtypen ohne Reservationen aufgeführt werden. Ausserdem sollen All- und Nullwerte unterschieden werden.
    The number of reservations grouped over all possible combinations of the dimensions member (member number) and vehicle type such that also types and members without reservations are shown. In addition distinguish all and null values.
    hint difficulty

  95. Anzahl Reservationen hierarchisch gruppiert nach Jahr, Monat und Tag des Reservationsbeginns
    The number of reservations hierarchically grouped over year, month, and day of the reservation begin
    hint difficulty

  96. alle Benutzer, die fern der Heimat reserviert haben (Fahrzeugstandort <> Heimatstandort des Benutzers)
    all members who have reserved a vehicle at a location other than their home location
    difficulty

  97. alle Benutzer, die fern der Heimat reserviert haben (Fahrzeugstandort <> 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

  98. alle Benutzer, die fern der Heimat reserviert haben (Fahrzeugstandort <> 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

  99. ein Belegungsplan fuer das Auto '194 SUA' fuer den 11.11. 2017 und die folgenden beiden Tage
    a free/busy plan for the vehicle '194 SUA' for 11.11. 2017 and the following two days
    hint difficulty

  100. ein Belegungsplan fuer die Station Greifensee fuer den 11.11. 2017
    a free/busy plan for the location Greifensee for 11.11. 2017
    hint difficulty


  101.  

Weiterführende Informationen

Title

Teaser text