2
0

change task from tomorrow

This commit is contained in:
Schuledaniel
2025-12-12 07:53:10 +01:00
parent 3a3c99701f
commit e59c3c4e59
2 changed files with 20 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
SELECT ProductID, SUM(Quantity) AS orderAnzahl SELECT bibNr, COUNT(*) AS orderAnzahl
FROM OrderDetails FROM Ausleihe
GROUP BY ProductID GROUP BY bibNr
ORDER BY orderAnzahl ASC; HAVING COUNT(*) > 10;

View File

@@ -28,7 +28,7 @@
### 2.3 SQL ### 2.3 SQL
## 2.3.1 ## 2.3.1
### Meine Lösung
```sql ```sql
SELECT book.bibNr, book.titel, COUNT(book.bibNr) AS wieOftAusgeliehen SELECT book.bibNr, book.titel, COUNT(book.bibNr) AS wieOftAusgeliehen
FROM buch AS book FROM buch AS book
@@ -37,10 +37,24 @@ LEFT JOIN Ausleihe AS rent ON book.bibNr = rent.bibNr
GROUP BY book.bibNr, book.titel GROUP BY book.bibNr, book.titel
ORDER BY wieOftAusgeliehen ASC ORDER BY wieOftAusgeliehen ASC
``` ```
### Lösung des Lehrers
```sql
SELECT a.bibNr, b.titel, COUNT(*) AS wieOftAusgeliehen
FROM Ausleihe, Buch
WHERE AUsleihe.bibNr=Buch.bibNr
WHERE Aulsiehe.ausleihdatum BETWEEN "2015-01-01" AND "2015-12-32"
GROUP BY bibNr, titel
ORDER BY COUNT(*) DESC;
```
## 2.3.2 ## 2.3.2
X ```sql
SELECT bibNr, COUNT(*) AS orderAnzahl
FROM Ausleihe
GROUP BY bibNr
HAVING COUNT(*) > 10; -- HAVING bei solchen funktionen
```
## 2.3.3 ## 2.3.3