sub query and AS

Поиск
Список
Период
Сортировка
От Ferruccio Zamuner
Тема sub query and AS
Дата
Msg-id 4FBCACB7.9070501@diff.org
обсуждение исходный текст
Ответы Re: sub query and AS  (Lee Hachadoorian <Lee.Hachadoorian+L@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Carlos Mennens
Дата:
Сообщение: Understanding Binary Data Type
Следующее
От: Gary Stainburn
Дата:
Сообщение: left outer join only select newest record