Re: how to create aggregate xml document in 8.3?
От
Matt Magoffin
Тема
Re: how to create aggregate xml document in 8.3?
Дата
Msg-id
50163.192.168.1.108.1197414121.squirrel@msqr.us
Ответ на
Список
Дерево обсуждения
how to create aggregate xml document in 8.3? "Matt Magoffin" <postgresql.org@msqr.us>
Re: how to create aggregate xml document in 8.3? Tom Lane <tgl@sss.pgh.pa.us>
Re: how to create aggregate xml document in 8.3? "Matt Magoffin" <postgresql.org@msqr.us>
Re: how to create aggregate xml document in 8.3? Tom Lane <tgl@sss.pgh.pa.us>
Re: how to create aggregate xml document in 8.3? "Matt Magoffin" <postgresql.org@msqr.us>
> "Matt Magoffin" writes:
>> Hello, I'm trying to write a query to return an XML document like
>>
>>
>>
>> ...
>>
>
> Something like this:
>
> regression=# select xmlelement(name root, xmlagg(x)) from
> regression-# (select xmlelement(name range, xmlattributes(string4,
> count(*) as count)) as x from tenk1 group by string4) ss;
> xmlelement
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
> count="2500"/> string4="VVVVxx" count="2500"/>
> (1 row)
>
> You need a subquery because your setup requires two levels of
> aggregation: one to make the grouped counts, and then another one
> for the xmlagg() (which is basically just text concatenation).
Thanks very much, that helps. Now I'm wondering if it's also possible to
then fill in another nested element level in the XML output, from the rows
that are aggregated into the count. So from your example,
something like
....
....
Any thoughts on this?
-- m@
В списке pgsql-general по дате отправления