Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何获取表中每个项目的最大值_Php_Mysql_Sql - Fatal编程技术网

Php 如何获取表中每个项目的最大值

Php 如何获取表中每个项目的最大值,php,mysql,sql,Php,Mysql,Sql,如何获取表中每个项目的最大值 我想在“num\u place”的任何地方都有一个最受欢迎的名字“name\u p” 这一结果:- 但这是我需要的结果 这可以产生您想要的结果,但对于数字位置3,可以任意选择“e”或“h”,因为它们是并列的: select name_p, num_place, couny_pla from ( select name_p, num_place, row_number() over (partition by num_place order by coun

如何获取表中每个项目的最大值

我想在“num\u place”的任何地方都有一个最受欢迎的名字“name\u p”

这一结果:-

但这是我需要的结果


这可以产生您想要的结果,但对于数字位置3,可以任意选择“e”或“h”,因为它们是并列的:

select name_p, num_place, couny_pla
from (
    select name_p, num_place, row_number() over (partition by num_place order by couny_pla desc) n, count(*) couny_pla
    from selec_user
    group by name_p, num_place 
) ranked_groups
where n=1
order by num_place;
如果希望返回所有绑定值,请将
行编号()
替换为
rank()


什么是
选择版本()显示?10。4.8-MariaDBYou可能会在任何时候向您的问题中添加重要的细节。如果两个姓名和数字之间出现并列,该怎么办?取较低的数值?您能解释一下为什么
h
不在所需的结果集中吗?
select name_p, num_place, couny_pla
from (
    select name_p, num_place, row_number() over (partition by num_place order by couny_pla desc) n, count(*) couny_pla
    from selec_user
    group by name_p, num_place 
) ranked_groups
where n=1
order by num_place;