开发者

Frequency Table by user in SQL

开发者 https://www.devze.com 2023-01-01 21:58 出处:网络
Very basic SQL question (DB is MySQL): I want a table of number of transactions by users. User IDTransaction count

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号