Create temporary table with fixed values

postgresql, sql, temporary

Solution

If you only need the temp table for one SQL query, then you can hard-code the data into a Common Table Expression as follows :

WITH temp_table AS
(
  SELECT 'Zoom' AS AC UNION
  SELECT 'Inci' UNION
  SELECT 'Fend'
)
SELECT * FROM temp_table

see it work at http://sqlfiddle.com/#!15/f88ac/2 (that CTE syntax also works with MS SQL) HTH

Problem

How do I create a temporary table in PostgreSQL that has one column "AC" and consists of these 4-digit values: - Zoom - Inci - Fend In essence the table has more values, this should just serve as an example.

Original source

Related problems