我有一个以下查询,它根据订单优先级给出记录。我想把这个传统的 mySql 查询翻译成 rails ORM,但我做不到。
我的查询如下:
SELECT *
FROM user_questions q
WHERE question_sequence_number IN (11,13,16,19)
OR id IN (198,199,200,201,202)
ORDER BY (question_sequence_number IN (11,13,16,19)) DESC,
CASE WHEN question_sequence_number IN (11,13,16,19)
THEN question_sequence_number
ELSE id
END
有人可以帮我解决这个问题吗?