从sqlite数据库中获取随机行,然后按列排序

Get random rows from sqlite database, then sort by column

对于每个新查询,我想从 table tasks 中随机获取一组 10 行。然后应按列 difficulty.

对行进行排序

我试过了,但是 difficulty 的订单被忽略了:

SELECT id, difficulty
FROM tasks
ORDER BY random(), difficulty
LIMIT 10

首先在子查询中获取10个随机行,然后按difficulty:

排序
SELECT *
FROM (
  SELECT id, difficulty
  FROM tasks
  ORDER BY random()
  LIMIT 10
)
ORDER BY difficulty;