Skip to content
Advertisement

SQL Order By in Custom Sequence [closed]

I have data in this order

How can I sort this data in this order?

Advertisement

Answer

To do this requires a big assumption which is that the original sequence is reproducible somehow. Just by entering those rows into a database without a sequence we would be unable to be guaranteed to reproduce the result.

This code assigns a sequence to the original data. Using the column o_seq the ORDER BY produces the requested order.

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