SELECT DISTINCT t.FAULT_CODE AS "dataIndex", t.FAULT_NAME AS "title" FROM FAULT_TYPE t WHERE t.PAR_FAULT_CODE = t.FAULT_CODE UNION ALL SELECT COALESCE('reportCount', 'N/A') AS "dataIndex", '合计' AS "title" FROM DUAL怎么根据FAULT_CODE排序
时间: 2024-02-10 22:08:08 浏览: 86
CBST.rar_The Keys_bst
可以在UNION ALL语句后面添加一个ORDER BY子句来对查询结果进行排序,以下是一个示例:
```
SELECT DISTINCT t.FAULT_CODE AS "dataIndex", t.FAULT_NAME AS "title"
FROM FAULT_TYPE t
WHERE t.PAR_FAULT_CODE = t.FAULT_CODE
UNION ALL
SELECT COALESCE('reportCount', 'N/A') AS "dataIndex", '合计' AS "title"
FROM DUAL
ORDER BY "dataIndex" ASC;
```
其中,ORDER BY子句中的"dataIndex"是要排序的列名,ASC表示升序排序(也可以使用DESC表示降序排序)。注意,在Oracle数据库中,列名是区分大小写的,因此要使用引号将列名括起来。
阅读全文