gpt4 book ai didi

mysql - 订单不工作 - MYSQL

转载 作者:搜寻专家 更新时间:2023-10-30 20:26:38 24 4
gpt4 key购买 nike

SELECT chars, pts, FIND_IN_SET( pts, (
SELECT GROUP_CONCAT(pts ORDER BY pts DESC,chars ASC) FROM table ) ) AS rank
FROM table WHERE chars = 'Ueki'

我想得到的是:我试图在订购字母(字符)和数字(pts)后获得字符的等级。

但由于某些原因,字符排序不起作用

表:

+--------------------+
| chars | pts |
+--------------------+
| abc | 4 |
+--------------------+
| Ueki | 3 |
+--------------------+
| Ueka | 3 |
+--------------------+

结果:

(WHERE chars = 'Ueki')
+------------------------------+
| chars | pts | rank |
+------------------------------+
| Ueki | 3 | 3 |
+------------------------------+

(WHERE chars = 'Ueka')
+------------------------------+
| chars | pts | rank |
+------------------------------+
| Ueka | 3 | 2 |
+------------------------------+

最佳答案

I am trying to get the rank of a charecter after ordering them, alphabetically (chars) and numerically (reps).

对于 reps,我假设您指的是 pts

如果这是您想要的顺序,那么这些子句对于 order by 的顺序是错误的:

SELECT chars, pts,
FIND_IN_SET(pts,
(SELECT GROUP_CONCAT(pts ORDER BY chars ASC, pts DESC)
FROM table
)
) AS rank
FROM table
WHERE chars = 'Ueki';

关于mysql - 订单不工作 - MYSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30752294/

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