我在这里得到了这段代码:
select DealID,ExternalReference,order_number, sales_rule
from flostream.orders
join mobileheads.surveys on flostream.orders.ExternalReference = mobileheads.surveys.order_number
//where DealID is null
我想要发生的是IF DealID(在flostream.orders中)为null,将其替换为sales_rule(在mobileheads.surveys中)
如果可以通过Bigquery完成此操作或者您是否可以考虑某些解决方法,请告诉我们?
谢谢!
的Nik
答案 0 :(得分:2)
你需要
IFNULL(expr, null_default)
If expr is not null, returns expr, otherwise returns null_default.
您应该在manual中详细了解它们。
您的查询如下:
SELECT IFNULL(DealID,sales_rule) as DealID,
ExternalReference,
order_number,
sales_rule
FROM flostream.orders
JOIN mobileheads.surveys ON flostream.orders.ExternalReference = mobileheads.surveys.order_number