0
我有一個下面的查詢,它根據訂單優先級給出記錄。我想將這個傳統的mySql查詢翻譯成rails ORM,但我無法做到這一點。
我的查詢如下:
如何將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
任何人可以請幫我在這?