I am building a reporting tool and I need to execute queries on remote databases and store the result set in my own database (because I do not have write permission on remot
As sepcified here you can do it in plain SQL like so:
CREATE TABLE artists_and_works
SELECT artist.name, COUNT(work.artist_id) AS number_of_works
FROM artist LEFT JOIN work ON artist.id = work.artist_id
GROUP BY artist.id;