2

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.

1 Answer 1

1

you can always use union all:

create table T as
select * from ...
union all
select * from ...
union all
...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.