ORDER BY具有相同优先级的不同列

jue*_*n d 2 sql sql-server

我有一个包含2个日期列的表:

create_datemodify_date.
create_date总是modify_date有时候设定.

现在我想用两个具有相同优先级的查询来命令我的查询.

如果我这样做:

order by create_date desc, modify_date desc
Run Code Online (Sandbox Code Playgroud)

我首先得到排序的所有行create_date然后按,modify_date但我希望按两个行排序的行具有相同的优先级.我需要这个:

create_date  |  modify_date
2011-12-31   |  -
2011-12-01   |  2011-12-30
2011-12-29   |  -
Run Code Online (Sandbox Code Playgroud)

And*_*rew 5

select *
from yourtable
order by coalesce(modify_date, create_date) desc
Run Code Online (Sandbox Code Playgroud)