SQL查询所需的输出

时间:2015-09-26 12:28:48

标签: sql

我有一张包含国家/地区的表格:

Countries
============
Australia
South Africa
Bangladesh
New zeland
Sri Lanka
England
...

Desired out put is

Country
===========
India
Sri Lanka
Followed by other countries in `Asc` or `Desc`

1 个答案:

答案 0 :(得分:2)

您可以使用CASE

<强> SqlFiddleDemo

SELECT *
FROM Countries
ORDER BY
  CASE Name
     WHEN 'India' THEN 0
     WHEN 'Sri Lanka' THEN 1
     ELSE 10
  END ASC,
  Name ASC -- DESC