开发者

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
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜