想从Oracle查询

时间:2016-03-02 11:47:55

标签: asp.net oracle

通过以下查询,我生成datable,其图表如下: -

SELECT   *
FROM (SELECT DISTINCT sv.mkey, vehicle_no,
                      CASE
                         WHEN sv.audit_flag = 'N'
                            THEN 'REJECTED'
                         ELSE 'PENDING APPROVAL'
                      END isnullcheck,
                         TO_CHAR (date_in,
                                  'dd-MM-yyyy'
                                 )
                      || ' & '
                      || time_in vehicleindate_time,
                         TO_CHAR (date_out,
                                  'dd-MM-yyyy'
                                 )
                      || ' & '
                      || time_out vehicleoutdate_time,
                      gate_no_in || ' & ' || gate_no_out ingate_outgateno,
                      remark_in remarkin, NULL receipt_no, date_in,
                      CASE
                         WHEN sv.audit_flag = 'N'
                            THEN 'Y'
                         ELSE 'N'
                      END hod
                 FROM xxcus.xxgid_audit_entry sv
                WHERE sv.project_id = '1365'
                  AND (sv.audit_flag IS NULL OR sv.audit_flag = 'N')
      UNION
      SELECT NULL, NULL, 'PENDING APPROVAL', NULL, 'PENDING APPROVAL',
             NULL, NULL, NULL, NULL, NULL
        FROM DUAL
      UNION
      SELECT NULL, NULL, 'REJECTED', NULL, 'REJECTED', NULL, NULL, NULL,
             NULL, NULL
        FROM DUAL) qq

ORDER BY isnullcheck DESC

生成的datable如下所示 [![DATATABLE] [1] [1]

现在我想要的是什么。 查询将结果提取为两个标题 即。 1. 拒绝或2. 待批准  但是这里发生的事情是除了标题之外还有其他事情。它不应该去。

[![图像] [2] [2]

另见网格的html

如何在两个标题下制作?查询有什么问题吗?

1 个答案:

答案 0 :(得分:1)

按其他方式排序,并使用NULLS FIRST:

ORDER BY isnullcheck DESC, mkey NULLS FIRST