Re: Generating a range of integers in a query

From: Scott Marlowe <smarlowe(at)g2switchworks(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 16:54:30
Message-ID: 1121273670.8208.251.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 2005-07-13 at 04:13, Aaron Bingham wrote:
> Hello,
>
> I've got an interesting problem: I need to select all possible values
> of an attribute that do /not/ occur in the database.
>
> 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 here:

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

specifically, the generate_series() function.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message TJ O'Donnell 2005-07-13 17:24:01 Re: [SQL] dynamically loaded functions
Previous Message David Blankley 2005-07-13 16:06:35 Re: Dynamic Offset Determination