首先订购NULLS

时间:2014-01-29 08:12:44

标签: sql oracle plsql sql-order-by

我想在3个表中选择一些列。我对此 ORDER BY NULLS FIRST 有疑问。已经2个小时了,它还在装载。我认为我的脚本是错误的或我需要添加的东西。这是我的脚本,它正在运行..

SELECT (CASE WHEN a.column1 IS NULL
             THEN 'ACTIVE'
             ELSE 'INACTIVE'
             END) as STATUS_DEF, <<some columns>>,

       (CASE WHEN b.column1 IS NULL
             THEN 'Active'
             ELSE) as STATUS_fnd_user, <<some columns>>,

                       c.column1||','||c.column2||','||c.column3

FROM table1 a, table2 b, table3 c

然后我想通过有效对它们进行排序首先,这就是我使用 ORDER BY NULLS FIRST 的原因。我试过了..

ORDER BY  a.column1, b.column1  NULLS FIRST;

还有其他想法吗?

1 个答案:

答案 0 :(得分:2)

感谢a_horse_with_no_name:)

...主动

FROM table1 a JOIN table2 b ON a.column1 IS NULL JOIN table3 c ON b.column1 IS NULL

无效...

FROM table1 a JOIN table2 b ON a.column1 = a.column1 JOIN table3 c ON b.column1 = b.column1