Home > database >  Query to put two rows together on Google Big Query?
Query to put two rows together on Google Big Query?

Time:09-29

I have two tables with similar structures on Google Big Query:

TABLE 1

dt_sell cod_material cod_channel
2022-01-01 12 vd
2022-01-02 14 vd

TABLE 1

dt_sell cod_material cod_channel
2022-01-01 12 ecm
2022-01-01 13 ecm

I need to put the rows of one table under the other one, like this:

dt_sell cod_material cod_channel
2022-01-01 12 vd
2022-01-02 14 vd
2022-01-01 12 ecm
2022-01-01 13 ecm

How could I do this by running a query on Big Query? I can't create a new table for it, it needs to be on a query.

CodePudding user response:

Consider using UNION

SELECT dt_sell, cod_material, cod_channel FROM table_one
UNION 
SELECT dt_sell, cod_material, cod_channel FROM table_two
  • Related