sql-server - SQL Server 中的条件排序依据
问题描述
我在处理带有条件顺序的查询时遇到了一些困难。这是一个示例数据:
|Id | Date-In | Date-Out |
|1 | 01/01/21 | NULL |
|2 | 03/01/21 | NULL |
|3 | 05/01/20 | 11/01/21 |
|3 | 12/01/21 | NULL |
|4 | 12/12/21 | 15/01/21 |
|5 | 17/01/21 | 21/01/21 |
我想像这样对数据进行排序:
|Id | Date-In | Date-Out |
|5 | 17/01/21 | 21/01/21 |
|4 | 12/12/20 | 15/01/21 |
|3 | 05/01/21 | 11/01/21 |
|3 | 12/01/21 | NULL |
|2 | 03/01/21 | NULL |
|1 | 01/01/21 | NULL |
有搬出分类
时 DESC 有搬出和搬入分类时 搬出 DESC、搬入 DESC、Id DESC(粗体) 其他分类搬入 DESC
解决方案
推荐阅读
- angular - 带有 Angular 的 Chrome 扩展 - 进行 REST API 调用
- perl - perl DBI 安装失败 alpine
- node.js - 角度和节点js中的zip文件上传问题
- windows - 更改具有无效证书的网页的浏览器行为
- reactjs - 如何在自定义挂钩的回调中保持更新的反应上下文值
- r - 使用一个数据的列值并将其用于绘制另一个数据
- python - 由于我们有旧版本的 Flask,因此未添加来自烧瓶的 SameSite cookie
- autodesk-forge - Autodesk Forge 将 DWG 上的许多布局转换为 PDF
- objective-c - NSSound 停止功能
- node.js - 如何根据 MongoDB 数据库中的键获取多个结果?