Thank you for answer.
It is useful.
Just a small doubt.
----------
insert into table1 values
('A'),('B'),('C'),('D'),('E'),('F'),(' ');
----
I have one empty value in table1.
After using the above query my output is:
------------
Name
C
F
A
B
D
E
-----------
But ' ' (Empty value) should come as 1st value.
something like:
-------------
Name
C
F
A
B
D
E
----------
Yep.
You would specify the order of preference in the first portion of the clause as follows
order by case when b.name is not null then 2
when a.name='' then 1
when b.name is null then 3
end,
a.name