I have two select statements that work on their own, but not together.
It:
SELECT MAX(a2.Fachanzahl)
FROM C17_AbfrageBView a2;
works and returns one row with one column with value 2
It:
SELECT a1.PersonID, a1.Vorname, a1.Nachname, MAX(a1.Fachanzahl) Fachanzahl
FROM C17_AbfrageBView a1
GROUP BY a1.PersonID, a1.Vorname, a1.Nachname
HAVING MAX(a1.Fachanzahl) = 2;
works and returns the correct string.
However, this:
SELECT a1.PersonID, a1.Vorname, a1.Nachname, MAX(a1.Fachanzahl) Fachanzahl
FROM C17_AbfrageBView a1
GROUP BY a1.PersonID, a1.Vorname, a1.Nachname
HAVING MAX(a1.Fachanzahl) = (
SELECT MAX(a2.Fachanzahl)
FROM C17_AbfrageBView a2
);
returns nothing (it should return the same string as the previous statement), although the external and internal selection commands work on their own. What is the problem?
Thank!
source
share