postgres inline table - ghdrako/doc_snipets GitHub Wiki

WITH  vals (k,v) AS (VALUES (0,-9999), (1, 100)) 
SELECT * FROM vals;
SELECT f.*
  FROM films f, (VALUES('MGM', 'Horror'), ('UA', 'Sci-Fi')) AS t (studio, kind)
  WHERE f.studio = t.studio AND f.kind = t.kind;
SELECT * FROM 
(VALUES 
  (1, 101), 
  (2, 202), 
  (3, 303), 
  (4, 304)
) as i(zone_number, output_type_id)
JOIN 
(SELECT 1 zone_number, 101 as output_type_id
 UNION ALL
 SELECT 2 zone_number, 202 as output_type_id
 UNION ALL
 SELECT 3 zone_number, 303 as output_type_id
) mappings on mappings.zone_number = zone.zone_number