Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下内容:
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 ......
这些值只是为了了解我在说什么!先感谢您!
使用AVG聚合:
AVG
SELECT UserId, AVG(Number) FROM YourTable GROUP By UserId
SQL 小提琴演示
SELECT UserID, AVG(Number) AS Average FROM YourTable GROUP BY UserID