我要求按字母顺序排列国家/地区列表,但要在TOP上指定特定国家/地区.在该国家之后,应按字母顺序排序.例
India
Afghanistan
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antigua and Barbuda
Argentina
Armenia
Aruba
Run Code Online (Sandbox Code Playgroud)
...........我尝试了这里提供的答案将某些值排序到顶部 但它无法正常工作我正在使用PL/SQl开发工具.Thanx提前
The*_*ver 13
这样的事情应该有效:
MySQL VERSION
ORDER BY (country = 'India') DESC, country ASC
Run Code Online (Sandbox Code Playgroud)
- 要么 -
ORDER BY
CASE
WHEN country = 'India' THEN 1
ELSE 2
END,
country ASC
Run Code Online (Sandbox Code Playgroud)
ORACLE版本
ORDER BY
CASE
WHEN country = 'India' THEN 1
ELSE 2
END
Run Code Online (Sandbox Code Playgroud)
或者你可以在顶部有多个特定值:
ORDER BY
CASE
WHEN country = 'India' THEN 1
WHEN country = 'United Kingdom' THEN 2
ELSE 3
END
Run Code Online (Sandbox Code Playgroud)