Porg - Laith SJ Porg - Laith SJ - 7 months ago 11
SQL Question

How to show All names in order from Employee table and make one of the names shows up first

We have an

Ename
column in the
employee
table containing the following names:

ENAME
-----
Laith
indi
Cup
Odai


How can I show the all the names from the employee table in alphabetical order but make
Odai
show at the top of the list? Like this:

ENAME
-----
Odai
Cup
indi
Laith

Answer
Select Name
From Employees
Order By Case When Name = 'Odai' Then ' ' Else Name End

If you want multiple names to be treated this way you can have an OrderBy Table with Name and SortName and join it to Employees and order by OrderBy.SortName