in reply to Re^2: Counting events and getting top 5 matches
in thread Counting events and getting top 5 matches

With LIMIT 5 you get the top 5 within the whole table. What the OP wanted is the top 5 for every value of code. It can be obtained without RANK but you need a subquery (or perhaps two) and this can reduce performances.

Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

  • Comment on Re^3: Counting events and getting top 5 matches