sql: can i do a max(count(*)) ?

Posted by every_answer_gets_a_point on Stack Overflow See other posts from Stack Overflow or by every_answer_gets_a_point
Published on 2010-03-13T00:55:19Z Indexed on 2010/03/13 0:57 UTC
Read the original article Hit count: 492

Filed under:

here's my code:

    select yr,count(*)  from movie
join casting on casting.movieid=movie.id
join actor on casting.actorid = actor.id
where actor.name = 'John Travolta'
group by yr

here's the question

 Which were the busiest years for 'John Travolta'. Show the number of movies he made for each year.

here's the table structure

movie(id, title, yr, score, votes, director)
actor(id, name)
casting(movieid, actorid, ord)

this is the output i am getting:

yr  count(*)
1976    1
1977    1
1978    1
1981    1
1994    1
etcetc

i need to get the rows for which count(*) is max

how do i do this?

© Stack Overflow or respective owner

Related posts about sql