Temporary constant table (with).
authorOleksandr Gavenko <gavenkoa@gmail.com>
Tue, 16 Jun 2020 14:44:06 +0300
changeset 2421 07304e8a9820
parent 2420 da418d28831e
child 2422 242e08fa2c73
Temporary constant table (with).
postgres.rst
--- a/postgres.rst	Tue Jun 16 14:37:50 2020 +0300
+++ b/postgres.rst	Tue Jun 16 14:44:06 2020 +0300
@@ -639,7 +639,13 @@
   SELECT num, str FROM (
     VALUES (1, 'a'), (2, 'b'), (3, 'c')) AS tbl(num, str);
 
+  WITH tbl(num, str) AS (VALUES (1, 'a'), (2, 'b'), (3, 'c'))
+  SELECT num, str FROM tbl;
+
 To generate table::
 
   SELECT val FROM generate_series(1, 10) val;
 
+  WITH t AS (SELECT val FROM generate_series(1, 10) val)
+  SELECT * FROM t;
+