Reputation: 13
SELECT DISTINCT
utover.startnr, utover.navn
FROM
utover, deltakelse
WHERE
utover.startnr = (SELECT utover
FROM deltakelse
GROUP BY utover
HAVING COUNT(*) = (SELECT COUNT(*)
FROM deltakelse
GROUP BY utover
ORDER BY COUNT(*) DESC
LIMIT 1)
LIMIT 1);
Here is the code I am using to get one of the two answers. I just wonder if it is possible to get more than one answer out somehow?
Upvotes: 0
Views: 36
Reputation: 1269923
First, you don't need the table deltakelse
in the from
clause. Without this, you can probably get rid of the distinct
.
The answer to your question is to change the =
to an in
:
SELECT utover.startnr, utover.navn
FROM utover
WHERE utover.startnr in (SELECT utover
FROM deltakelse
GROUP BY utover
HAVING COUNT(*) = (SELECT COUNT(*)
FROM deltakelse
GROUP BY utover
ORDER BY COUNT(*) DESC
LIMIT 1
)
);
Upvotes: 1