2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-25 22:38:04 +02:00
LaTeX-examples/documents/musterloesung-db-klausur-b/d3e.sql
Stefan Koch 097d360423 MAX in WHERE not possible
You cannot use MAX() in a WHERE clause, instead use a subquery.

The ORDER BY is also unneeded, because we only select the maximum. So what to order, there is only one number (even if multiple entries with the same number).
2013-07-30 11:18:13 +02:00

4 lines
186 B
SQL

SELECT berater_id, name, anzahl
FROM Beratungsanzahl
JOIN Berater ON Berater.berater_id = Beratungsanzahl.berater_id
WHERE anzahl = (SELECT MAX(anzahl) FROM Beratungsanzahl)