I'm trying to create view that will summarize data in two tables. Each table have several columns, but they both have NAME and AREA columns. And I want these two columns to be united correspondingly in view. I tried to create view using following query:
CREATE VIEW summary AS INSERT INTO (SELECT Name, SUM(Area) FROM table1 GROUP BY Name) SELECT * FROM (SELECT Name, SUM(Area) FROM table2 GROUP BY Name)
But I get the error:
SQL error: near "INSERT": syntax error. Actually I tried different querys involving INSERT INTO and it seems that CREATE VIEW will not work with INSERT INTO, and INSERT INTO does not accept subquery - only existing table (even temporal) would do.
How to rewrite CREATE VIEW statement to achieve my goal?