gpt4 book ai didi

mysql获取订单号

转载 作者:行者123 更新时间:2023-11-29 02:26:43 25 4
gpt4 key购买 nike

我有以下结构


国家 - 用户 ID - 积分

840 23 24
840 32 31
840 22 38
840 15 35
840 10 20
250 15 33
724 17 12

等等

我想根据积分获取用户在各个国家排名中的位置

我正在使用

select @rownum:=@rownum+1 Num, Country, UserId, points 
from users , (SELECT @rownum:=0) r
where country=840 order by points DESC ;

我想获得一个用户在他所在国家/地区的位置

在此示例中,在国家/地区 840,如果我选择用户 id=23,我将获得位置 4

国家 - UserId - 积分 - 订单
840 22 38 1
840 15 35 2
840 32 31 3
840 23 24 4
840 10 20 5

最佳答案

尝试做:

select * from (
select @rownum: = @rownum + 1 Num,
Country,
UserId,
points
from users, (select @rownum: = 0) r
where country = 840
order by points desc
) a
where userId = 23

关于mysql获取订单号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20398105/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com