试试这个: For MySQL: ``` SELECT T.Letter FROM Your_Table T JOIN ( SELECT * ,RAND()RandumNum FROM( SELECT DISTINCT Letter FROM Your_Table )D )E ON E.Letter = T.Letter ORDER BY E.RandumNum
检查一下这把小提琴 `For Sqlite:` ```
CREATE TEMP TABLE tempEmployees AS
SELECT Letter,RANDOM()RandumNum
FROM Your_Table
GROUP BY Letter
;
SELECT T.Letter
FROM Your_Table T
JOIN tempEmployees E ON E.Letter = T.Letter
ORDER BY E.RandumNum;
2条答案
按热度按时间ijnw1ujt1#
这里有一种方法:
一种更简单的方法是对字母本身进行计算。这里有一种方法:
这是规范的,所以在一行中运行两次会返回相同的结果。
gxwragnw2#
试试这个:
For MySQL:
```SELECT T.Letter
FROM Your_Table T
JOIN (
SELECT *
,RAND()RandumNum
FROM(
SELECT DISTINCT Letter FROM Your_Table
)D
)E ON E.Letter = T.Letter
ORDER BY E.RandumNum
检查一下这把小提琴