I have 20 tables and I wanted to perform a same query from all of them. Subsequently, I want to add the result of the all the queries to a new table. Tables include temperature, coordinate and time_date columns. And query is about creating sub-set of each table. The resulted new table should include the result of each query. In other words it should include aforementioned 3 column which are filled by the result of query from different tables.
The aforementioned code which should be applied for all the tables. is:
select *
FROM s3
WHERE dt::timestamptz BETWEEN DATE '2007-09-14' AND DATE '2007-10-03'
AND extract(hour FROM dt::timestamptz) BETWEEN 8 AND 20
ORDER BY dt
As a result there should be a new table which include temperature, coordinate and time_date columns with respect to the output of the query form all the tables. Note: Sequence of filling is not important in a new table.