sub query and AS - Mailing list pgsql-sql

From Ferruccio Zamuner
Subject sub query and AS
Date
Msg-id 4FBCACB7.9070501@diff.org
Whole thread Raw
Responses Re: sub query and AS  (Lee Hachadoorian <Lee.Hachadoorian+L@gmail.com>)
List pgsql-sql
Hi,

I like PostgreSQL for many reasons, one of them is the possibility to 
use sub query everywhere. Now I've found where it doesn't support them.

I would like to use a AS (sub query) form.

This is an example:

First the subquery:

select substr(descr, 7, length(descr)-8)  from (select string_agg('" int,"',freephone) as descr          from (select
distinctfreephone                  from calendario order by 1               ) as a       ) as b;      substr 
 


-----------------------------------------------------------------------------------------------------------------------------------------------------------------
"800900420"int,"800900450" int,"800900480" int,"800900570" 
 
int,"800900590" int,"800900622" int,"800900630" int,"800900644" 
int,"800900688" int,"800900950" int
(1 row)

Then the wishing one:

itv2=#
select *  FROM crosstab('select uscita,freephone,id from calendario order by 
1','select distinct freephone from calendario order by 1')   --  following AS fails    AS (select 'uscita int, ' ||
substr(descr,7, length(descr)-8)          from (select string_agg('" int,"',freephone) as descr                  from
(selectdistinct freephone                          from calendario order by 1) as a               ) as b;       );
 
ERROR:  syntax error at or near "select"
LINE 4: ...stinct freephone from calendario order by 1') as (select 'us...

More is on http://paste.scsys.co.uk/198877

I think that AS must evaluate the sub query in advance.

It could be possible to have such behavior?


Best regards,          \ferz


pgsql-sql by date:

Previous
From: Carlos Mennens
Date:
Subject: Understanding Binary Data Type
Next
From: Gary Stainburn
Date:
Subject: left outer join only select newest record