2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-26 06:48:04 +02:00

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).
This commit is contained in:
Stefan Koch 2013-07-30 11:18:13 +02:00
parent d7e7613c30
commit 097d360423

View file

@ -1,5 +1,4 @@
SELECT berater_id, name, anzahl
FROM Beratungsanzahl
JOIN Berater ON Berater.berater_id = Beratungsanzahl.berater_id
WHERE anzahl = MAX(anzahl)
ORDER BY anzahl DESC
WHERE anzahl = (SELECT MAX(anzahl) FROM Beratungsanzahl)