简体   繁体   English

如何在mysql中选择最高值的总和

[英]How to select the highest sum of value in mysql

I have the table like this我有这样的桌子

id    rate_user_id   content_id     points  category_id
1      100              1                  5      1
2      101              1                  3      1
3      100              2                  8      1
4      103              2                  11     1

So I want to looking highest point of content in this category 1所以我想看看这个类别 1 中内容的最高点

Content_id 2 = 19 points . Content_id 2 = 19 点。

U can do this by你可以这样做

select content_id,sum(points) from user group by content_id order by sum(points) desc limit 1;从用户组中选择 content_id,sum(points) by content_id order by sum(points) desc limit 1;

Thanks谢谢

Something like就像是

SELECT MAX(Pts) FROM
    (SELECT SUM(points) Pts GROUP BY content_id) A

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM