Re: Generating a range of integers in a query

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: Aaron Bingham <bingham(at)cenix-bioscience(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Generating a range of integers in a query
Date: 2005-07-13 10:20:55
Message-ID: 053899DD-536A-4B3F-87B0-8961FDD38315@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Jul 13, 2005, at 6:13 PM, Aaron Bingham wrote:

> This would be easy (in my case at least) if there were a way to
> generate a table containing all integers between 1 and n, where n is
> the result of a subquery. In my case, n will be at most a few
> hundred. I would like to be able to generate this table as a
> subquery. Any ideas?

Take a look at generate_series(), available in v8.0 and above.

http://www.postgresql.org/docs/8.0/interactive/functions-srf.html

Michael Glaesemann
grzm myrealbox com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Graham Vickrage 2005-07-13 11:31:29 Re: Copy user privileges
Previous Message Aaron Bingham 2005-07-13 09:13:06 Generating a range of integers in a query