Simone Monteleone
Simone Monteleone

Reputation: 21

max count in having-clause

I have to find the actors appeared first most times.

Recital(opera,actor,character,appearingOrder)

i've tried in this way:

select distinct R1.Actor, count(R1.Actor) as nro
from Recital R1
where R1.AppOrd='1'
group by Actor
having max(nro)

but it returns an empty table. Thank You.

Upvotes: 2

Views: 923

Answers (1)

Tom
Tom

Reputation: 6663

This would show the top actor, however if there was a tie, it would only show one of the actors:

select R1.Actor, count(R1.Actor) as nro
from Recital R1
where R1.AppOrd='1'
group by R1.Actor
ORDER BY nro DESC
LIMIT 1;

Upvotes: 1

Related Questions