Skip to content
Advertisement

SQL Server Select query with IN() and order by the same

I need a SELECT query with an IN clause, as well as Order by:

This code returns 1, 2, 5, 7, 8, 64.

Now I need to return the same select in order

Output needs to be: 5, 64, 2, 8, 7, 1

In Mysql, field option is there, but SQL Server does not have such a field option.

Advertisement

Answer

In SQL-Server, when you want to order by something, you have to specifically spell it out.

Try this

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement