Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
modul:m290:learningunits:lu04:loesungen:l02 [2024/09/27 12:59] vdemirmodul:m290:learningunits:lu04:loesungen:l02 [2024/10/17 12:35] (aktuell) vdemir
Zeile 1: Zeile 1:
-====== LU05.S02 - SQL-DQL: Select from multiple tables======+====== LU06.S02 - SQL-DQL: Select from multiple tables======
  
  
Zeile 23: Zeile 23:
 There are two possible solutions.  There are two possible solutions. 
  
-**b1)**+**B1)**
 The first assignment is to search for the ID (SupplierID = 20) of the supplier and take that ID into our SELECT as follows:   The first assignment is to search for the ID (SupplierID = 20) of the supplier and take that ID into our SELECT as follows:  
  
Zeile 31: Zeile 31:
   AND s.SupplierID = 20;   AND s.SupplierID = 20;
  
-**b2)** +**B2)** 
 The second solution takes the name directly into the SELECT statement:   The second solution takes the name directly into the SELECT statement:  
  
Zeile 38: Zeile 38:
   WHERE p.SupplierID = s.SupplierID   WHERE p.SupplierID = s.SupplierID
   AND s.SupplierName = 'Leka Trading';   AND s.SupplierName = 'Leka Trading';
 +  
 The result set is in both cases, as the figure below shows:  The result set is in both cases, as the figure below shows: 
  
Zeile 46: Zeile 46:
 We would like to know what products the customer "Hanari Carnes" has ordered in the past. Sort the list by the quantity. In detail we require the following data: CustomerID, CustomerName, OrderID, OorderDate, Quantity, ProductName, CategoryName  We would like to know what products the customer "Hanari Carnes" has ordered in the past. Sort the list by the quantity. In detail we require the following data: CustomerID, CustomerName, OrderID, OorderDate, Quantity, ProductName, CategoryName 
  
-**c1)**+**C1)**
 Like in assignment b) here a two approaches possible: 1. find the customerID (34) and select according to the customer id. Like in assignment b) here a two approaches possible: 1. find the customerID (34) and select according to the customer id.
  
Zeile 58: Zeile 58:
   ORDER BY od.Quantity;   ORDER BY od.Quantity;
  
-**C1)** +**C2)** 
-The second approach, as in b2), is to filter the result set directly by customer name.+The second approach, as in B2), is to filter the result set directly by customer name.
  
   SELECT c.CustomerID, c.CustomerName, o.OrderID, o.orderDate, od.Quantity, p.ProductName, ct.CategoryName   SELECT c.CustomerID, c.CustomerName, o.OrderID, o.orderDate, od.Quantity, p.ProductName, ct.CategoryName
Zeile 70: Zeile 70:
   ORDER BY od.Quantity;       ORDER BY od.Quantity;    
      
-  The result set is in both cases as shown in the following figure.+The result set is in both cases as shown in the following figure.
      
 {{:modul:m290:learningunits:lu04:aufgaben:screenshot_2024-09-03_143510.png?600|}} {{:modul:m290:learningunits:lu04:aufgaben:screenshot_2024-09-03_143510.png?600|}}
  • modul/m290/learningunits/lu04/loesungen/l02.1727434794.txt.gz
  • Zuletzt geändert: 2024/09/27 12:59
  • von vdemir