Hi,
I am enjoying prisma a lot, thanks for making it so easy to use.
I was wondering what the best approach is to sum a column in a table, but have the sums grouped by a distinct relation.
For example, imagine you had a table of stockTrades, and each stockTrade row had a relation to a user who made the trade. Another column is the profit/loss for that trade. What is the most efficient way to grab each distinct user, and sum their total profit/loss? The only way I could think of was to grab each distinct user in one query, and then loop through each user and count each profit/loss, but that would create 1 query per user in the table which wouldn't scale well.
Thanks for any help!