Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
| modul:m290:learningunits:lu04:loesungen:l02 [2024/09/27 12:32] – vdemir | modul:m290:learningunits:lu04:loesungen:l02 [2024/10/17 12:35] (aktuell) – vdemir | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | ====== | + | ====== |
| Zeile 10: | Zeile 10: | ||
| The general assignment is to develop DQL commands that matches the requirements below: | The general assignment is to develop DQL commands that matches the requirements below: | ||
| - | ==== Assignment | + | ==== Assignment |
| We need a list with product details as following: Name of the supplier, Supplier phone, Product ID, Name of the product, units, price. The list must be be sorted by SupplierName in descending order. | We need a list with product details as following: Name of the supplier, Supplier phone, Product ID, Name of the product, units, price. The list must be be sorted by SupplierName in descending order. | ||
| Zeile 18: | Zeile 18: | ||
| ORDER BY s.SupplierName DESC; | ORDER BY s.SupplierName DESC; | ||
| - | ==== Assignment | + | ==== Assignment |
| Extend the the result of the Select statement from assignment a), so that it must contain only produtcs of the supplier "Leka Trading" | Extend the the result of the Select statement from assignment a), so that it must contain only produtcs of the supplier "Leka Trading" | ||
| 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: | ||
| {{: | {{: | ||
| | | ||
| - | ==== Assigmment | + | ==== Assigmment |
| We would like to know what products the customer " | We would like to know what products the customer " | ||
| - | **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, | SELECT c.CustomerID, | ||
| 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. |
| | | ||
| {{: | {{: | ||
| | | ||
| ===== Solution ===== | ===== Solution ===== | ||
| - | [[modul: | + | [[modul: |