I am running a pretty lengthy SQL query that at its core is pretty basic:
SELECT * FROM documents WHERE doc_id IN (995,941,940,954,953,973)
My goal result of this query is to then display the documents in the order in which they are set in the IN clause. However, I have yet to find a clean solution for doing so.
I thought I could use charindex() to handle this.
ORDER BY charindex('995,941,940,954,953,973',doc_id)
The result of that ORDER BY just orders the doc_ids in default ASC order.
Any guidance on how I could specifically define the result order this query?