How to get a specific record from a table as the last record? [duplicate]

拥有回忆 提交于 2019-12-11 15:19:24

问题


For example, I have a table in Oracle db where the values in a column are:

A
B
C
D

I would like to fetch the following output from the table(here, B,C,D are in alphabetical order and A is put to the last):

B
C
D
A

Note: They have a unique key with the column if that helps.


回答1:


Have a case expression in the ORDER BY to put A rows at the end:

order by case when columnname = 'A' then 1 else 0 end, columnname


来源:https://stackoverflow.com/questions/46726626/how-to-get-a-specific-record-from-a-table-as-the-last-record

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!