0

我有以下内容:

UserID | Number
1 | 100
1 | 200
1 | 300
2 | 20
2 | 21
2 | 22
3 | 333
......
.....
1000| 23
.......

and I want to get the following result:
UserID | Average
1 | 200
2 | 21
3 | 300
......
......
1000 | 200
......

这些值只是为了了解我在说什么!先感谢您!

4

2 回答 2

0

使用AVG聚合:

SELECT UserId, AVG(Number)
FROM YourTable
GROUP By UserId

SQL 小提琴演示

于 2013-05-06T16:38:46.513 回答
0
SELECT UserID, AVG(Number) AS Average
FROM YourTable
GROUP BY UserID
于 2013-05-06T16:38:54.740 回答