Fill array with series

From: Lee Hachadoorian <lee(dot)hachadoorian(at)gmail(dot)com>
To: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Fill array with series
Date: 2012-03-22 19:47:04
Message-ID: CANnCtnJuWDd_749QfxdW1iDVAxfmUBA4oVkZwmvWss_haynhGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Is there a single function that will generate a series and return an array?
The best I've come up with is to combine array_agg and generate_series:

SELECT array_agg(generate_series) FROM generate_series(5, 23);

array_agg
---------------------------------------------------------
{5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}

Thanks,
--Lee

--
Lee Hachadoorian
PhD, Earth & Environmental Sciences (Geography)
Research Associate, CUNY Center for Urban Research
http://freecity.commons.gc.cuny.edu/

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Pavel Stehule 2012-03-22 20:02:56 Re: Fill array with series
Previous Message Bear 2012-03-21 08:30:45 Problem with inserting data produced by the function (when the function is performed).