BigQuery IF field exists THEN

后端 未结 1 1172
隐瞒了意图╮
隐瞒了意图╮ 2020-12-11 18:17

I\'m running a query over multiple tables unioned together over a particular time range.

In the past, a particular field did not exist in the \"schema\" but about ha

1条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-11 18:55

    Below should give you direction

    SELECT * FROM
    (SELECT * FROM ),
    (SELECT * FROM )
    

    Assuming you have a, b and c as a fields in your original table () - above can be used (see below) if you need to change missing values from NULL to 0:

    SELECT a, b, c, COALESCE(my_field, 0) as my_field
    FROM
    (SELECT * FROM ),
    (SELECT * FROM )
    

    0 讨论(0)
提交回复
热议问题