Need special sort for a nation table [message #425092] |
Wed, 07 October 2009 08:08  |
MarkusW
Messages: 20 Registered: June 2009 Location: Austria
|
Junior Member |
|
|
hi,
need help for special sorting of a nation table.
id name
-----------------------
1 Frankreich
3 Niederlande
4 Deutschland
5 Italien
6 Grossbritannien
7 Irland
8 Dänemark
9 Zypern
10 Albanien
My job is to get a select, where the nation "Deutschland" is in the first row, all other nations are sorted by name, my result should like this
id name
------------------------
4 Deutschland
10 Albanien
8 Dänemark
1 Frankreich
6 Grossbritannien
5 Italien
7 Irland
3 Niederlande
9 Zypern
i try it with following select
select id, replace(name, 'AA', '') as name from
(
select id, ('AA' || name) as name from nation
where name like 'Deutschland%'
union
select id, name from nation
where name not like 'Deutschland%'
order by name
)
I thinks, this select is not very fast and a little hack, is there a better possibility to sort the nations with a case-when in the order clause or with an other SQL technique (group by or an order by with an special order algorithm?
thx 4 any help!
Mark
|
|
|
|
|