PostgreSQL table variable
Use a temporary table in PostgreSQL. For your example: CREATE TEMP TABLE product_totals ( product_id int , revenue money ); The manual about CREATE TABLE: If specified, the table is created as a temporary table. Temporary tables are automatically dropped at the end of a session, or optionally at the end of the current transaction … Read more