May 28, 2024
0
Level 1
Uniq player in top 10 tickets
I have two models: Ticket and Player. The relationship between them is one-to-many: one player can have multiple tickets, and each ticket belongs to one player.
I need help retrieving the top 10 tickets ordered by their score column, with the following constraints:
Each player can appear only once in the top 10. If a player has multiple tickets in the top 10, only their highest-scoring ticket should be included. If multiple tickets have the same score, the ticket with the smaller ID should be prioritized. Could you guide me on how to achieve this? The distinct method do not work here.
Please or to participate in this conversation.