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."
In reply to Re^3: Counting events and getting top 5 matches
by psini
in thread Counting events and getting top 5 matches
by iphony
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |