Apache Drill上的联合为NULL

时间:2018-05-03 15:29:04

标签: sql null apache-drill mapr

我有一个查询,我需要使用Union来获取单行中的所有日期。在联合中钻取不支持NULL。请注意,这是一个示例查询

name=""

2 个答案:

答案 0 :(得分:0)

select id, nullif(a_supplydate,'')a_supplydate, a_orderdate, nullif(b_supplydate,'')b_supplydate, b_orderdate from    
  (Select ID, Supplydate as A_SupplyDate,OrderDate as A_Orderdate,
           '' as B_SupplyDate,NULL as B_OrderDate 
           from tbl where Category='A'
    union
       Select ID, '' as A_SupplyDate,NULL as A_Orderdate,
           Supplydate as B_SupplyDate,OrderDate as B_OrderDate 
              from tbl where Category='B')A

答案 1 :(得分:0)

将您的null设置为适当的数据类型,例如cast(null as bigint)