在BigQuery中,可以使用IFNULL函数来替换空值。以下是一个使用IFNULL函数的示例代码:
SELECT IFNULL(column_name, replacement_value) AS new_column_name
FROM table_name
在上面的代码中,column_name是要检查的列名,replacement_value是要替换的值。如果column_name列的值为空,它将被替换为replacement_value。
例如,假设有一个包含订单信息的表,其中某些行的订单金额为空。要将空值替换为0,可以使用以下代码:
SELECT IFNULL(order_amount, 0) AS new_order_amount
FROM orders
这将返回一个名为new_order_amount的新列,其中包含替换了空值的订单金额。
下一篇:BigQuery - 格式化日期