Thanks Joe I'm very much learning as I go. I've followed your example from top to bottom - your sample code works - however its not clear to me how to execute the generate_crosstab_sql function to produce the results in one single step. I've tried this: CREATE OR REPLACE VIEW mycrosstabresults AS select * FROM (SELECT generate_crosstab_sql('mytable', 'rowid', 'text', 'rowdt::date', 'temperature', 'int', '1 = 1')) as crosstabresults; but this simply populates the view with the string below, not the actual crosstab results. SELECT * FROM crosstab ('SELECT rowid,rowdt::date,temperature FROM mytable WHERE 1 = 1 ORDER BY 1,2','VALUES($v$2003-03-01$v$),($v$2003-03-02$v$),($v$2003-03-03$v$)') AS (rowid text,"2003-03-01" int,"2003-03-02" int,"2003-03-03" int) Is it possible to incorporate and execute this string, all within my CREATE OR REPLACE VIEW statement? I would appreciate any help you can give. Many thanks -- View this message in context: http://postgresql.1045698.n5.nabble.com/Subquery-for-column-names-of-tablefunc-crosstab-queries-tp3351437p3374199.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general