Frequency Table by user in SQL
Very basic SQL question (DB is MySQL):
I want a table of number of transactions by users.
User ID Transaction count 1 43 2 开发者_Python百科 213 3 0 4 23 5 0
In a table I have the two relevant records (user_id and buy_count).
How could I get the table I want?
Thanks,
Roberto
Group By
SELECT user_id, SUM(buy_count)
FROM table
GROUP BY user_id
精彩评论