我有一个包含2个日期列的表:
create_date和modify_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)
select *
from yourtable
order by coalesce(modify_date, create_date) desc
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
623 次 |
| 最近记录: |