Search Postgresql Archives

On naming attributes in a WITH clause

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Is it possible to rename columns in a WITH clause which includes VALUES?

None of the following parse:

WITH map_table AS
(
    VALUES ('1','r'),('2','w'),('3','a'),('4','d') 
) AS (a,b)
SELECT * FROM map_table;

WITH map_table AS
(
    VALUES ('1','r'),('2','w'),('3','a'),('4','d') AS t (a,b)
) 
SELECT * FROM map_table;

I would like the map_table columns to have names other than column1 and column2.

WITH map_table AS
(
    VALUES ('1','r'),('2','w'),('3','a'),('4','d') 
) 
SELECT column1 AS a, column2 AS b FROM map_table;

is close but I would prefer to rename the columns as part of the WITH clause before the (poorly) named column1 and column2 hit the main query. Is it possible?

Cheers,
M
-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux