Link in SQL
This commit is contained in:
@@ -1611,19 +1611,19 @@ Gib den Ort und die durchschnittliche Magnitude jedes Ortes zurück und berücks
|
|||||||
Runde die Ergebnisse auf 2 Dezimalstellen.
|
Runde die Ergebnisse auf 2 Dezimalstellen.
|
||||||
|
|
||||||
| location | amplitude | period |
|
| location | amplitude | period |
|
||||||
| --- | --- | --- |
|
| -------- | --------- | ------ |
|
||||||
| Stonebri | 0.01 | 1 |
|
| Stonebri | 0.01 | 1 |
|
||||||
| Readat | 0.003 | 24 |
|
| Readat | 0.003 | 24 |
|
||||||
| Chelten | 5 | 0.2 |
|
| Chelten | 5 | 0.2 |
|
||||||
| Stonebri | 74 | 49 |
|
| Stonebri | 74 | 49 |
|
||||||
| Stonebri | 11 | 62 |
|
| Stonebri | 11 | 62 |
|
||||||
| Readat | 0.008 | 0.34 |
|
| Readat | 0.008 | 0.34 |
|
||||||
| Chelten | 73 | 13 |
|
| Chelten | 73 | 13 |
|
||||||
| Hamwyawi | 68 | 72 |
|
| Hamwyawi | 68 | 72 |
|
||||||
| Chelten | 3 | 1.2 |
|
| Chelten | 3 | 1.2 |
|
||||||
| Hamwyawi | 64 | 45 |
|
| Hamwyawi | 64 | 45 |
|
||||||
| Hamwyawi | 0.0005 | 1.2 |
|
| Hamwyawi | 0.0005 | 1.2 |
|
||||||
| Stonebri | 13 | 1.6 |
|
| Stonebri | 13 | 1.6 |
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
select location, round(avg((amplitude/period)*(amplitude/period) / period),2) as avg_magnitude from earthquakes where amplitude > 1 and period > 1 group by location having avg_magnitude > 1
|
select location, round(avg((amplitude/period)*(amplitude/period) / period),2) as avg_magnitude from earthquakes where amplitude > 1 and period > 1 group by location having avg_magnitude > 1
|
||||||
@@ -1647,7 +1647,7 @@ Wir benötigen eine Unterabfrage, weil wir `WHERE salary > AVG(salary)` nicht di
|
|||||||
SELECT id, salary
|
SELECT id, salary
|
||||||
FROM employees
|
FROM employees
|
||||||
WHERE salary > (
|
WHERE salary > (
|
||||||
SELECT AVG(salary)
|
SELECT AVG(salary)
|
||||||
FROM employees
|
FROM employees
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -1656,14 +1656,13 @@ Eine Unterabfrage hilft uns, Mitarbeitende zu finden, die mehr als das durchschn
|
|||||||
|
|
||||||
Da der Durchschnitt `(48 + 34 + 46 + 13 + 28) / 5 = 33.8` beträgt, ist dies das Ergebnis der Abfrage:
|
Da der Durchschnitt `(48 + 34 + 46 + 13 + 28) / 5 = 33.8` beträgt, ist dies das Ergebnis der Abfrage:
|
||||||
|
|
||||||
|id|Gehalt|
|
| id | Gehalt |
|
||||||
|---|---|
|
| ----------------------------------------------- | ------ |
|
||||||
|1|48|
|
| 1 | 48 |
|
||||||
|2|34|
|
| 2 | 34 |
|
||||||
|3|46|
|
| 3 | 46 |
|
||||||
Beispiel:
|
| Beispiel: | |
|
||||||
Produkte mit einem überdurchschnittlichen Preis
|
| Produkte mit einem überdurchschnittlichen Preis | |
|
||||||
|
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT name, price
|
SELECT name, price
|
||||||
@@ -1673,3 +1672,13 @@ WHERE price > (
|
|||||||
FROM products
|
FROM products
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
https://learnsql.de/blog/die-wichtigsten-sql-befehle/
|
||||||
|
|||||||
Reference in New Issue
Block a user