Just to explain: I have a users model, and users have many portfolios. Each portfolio has many positions, and each position belongs to a coin. I want to select the coin that is held by the greatest number of users, but am struggling a bit to come up with the correct query. I could imagine writing something like 'find the coin that has the most positions, where the user_ids of the positions are distinct'. Is that the right idea, and how does type that up?
Aucun commentaire:
Enregistrer un commentaire