dimanche 3 mai 2015

arrange mulitple column value

I tried to arrange the following table using the following command. The output is ordered ascendingly. Can anyone help to get the desired output.Thanks in advance.

SELECT x.TheColumn
FROM
(
SELECT DISTINCT Title as TheColumn, Title, 1 AS MyOrder
FROM Fables

UNION

SELECT TitleDisplay as TheColumn, Title, 2 AS MyOrder
FROM Fables
WHERE TitleDisplay IS NOT NULL
) x
ORDER BY x.Title, x.MyOrder, x.TheColumn;

Table:

Table Fables

Output:

output

Need output like

the wolf
chapter1.1
chapter1.2
the tortoise
chapter2.1
the crab
chapter3.1
the frog
chapter4.1

Aucun commentaire:

Enregistrer un commentaire