簡體   English   中英

如何通過單個查詢獲得兩個單獨的結果

[英]How to get two separate result with single query

我的目標是獲取每個人的積分之和,並返回用戶名和他/她的總積分。

id      |   username  |   points

1           Michelle       23
2           Chester        44
3           Michelle       13
4           Chester        23
5           Chester        65
6           Chester        43
7           Michelle       65
8           Chester        12
9           Michelle       54
10          Chester        76

願望結果

username   |  total_points

Chester    |  total points of Chester
Michelle   |  total points of Michelle

怎么樣:

SELECT      username, SUM(points) total_points
FROM        mytable
GROUP BY    username
ORDER BY    username

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM