From: | Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com> |
---|---|
To: | Marc-André Goderre <magoderre(at)cgq(dot)qc(dot)ca>, "'pgsql-general(at)postgresql(dot)org' (pgsql-general(at)postgresql(dot)org)" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: function returning a merge of the same query executed X time |
Date: | 2015-04-22 15:21:09 |
Message-ID: | 5537BC65.1070106@BlueTreble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 4/22/15 8:14 AM, Marc-André Goderre wrote:
> select row_to_json(q)
> from (select row_number() over() as id, sum(cost) as total_cost,sum(length) as total_length,json_agg(row_to_json(r)) as data
> from (select * from cm_get_loop_route_4(2, 10, -73.597070, 45.544083))r)q
Untested...
CREATE FUNCTION ...(
...
, iterations int
)
LANGUAGE sql AS
$body$
select row_to_json(q)
from (select row_number() over() as id, sum(cost) as
total_cost,sum(length) as total_length,json_agg(row_to_json(r)) as data
from (select * from cm_get_loop_route_4(2, 10, -73.597070, 45.544083))r)q
, generate_series(1, iterations) i
$body$
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com
From | Date | Subject | |
---|---|---|---|
Next Message | Geoff Winkless | 2015-04-22 15:21:51 | Re: function returning a merge of the same query executed X time |
Previous Message | Marc-André Goderre | 2015-04-22 13:14:28 | function returning a merge of the same query executed X time |