pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Broersma Jr <rabroersma@yahoo.com>
To: SQL Postgresql List <pgsql-sql@postgresql.org>
Subject: Joe Celko's method to "generate_series" not working?
Date: Wed, 2 May 2007 17:17:07 -0700 (PDT)
Message-ID: <649296.88043.qm@web31815.mail.mud.yahoo.com> (raw)

Well, I am about a book and a-half away from reading all of the Joe Celko's books that I know of.
I just came across an nice looking way to generate a series using a set oriented construct. 
However, I am not able to get it to work in PostgreSQL.

The method follows from the SQL Programming Style p.164:

SELECT hundred * 100 + ten * 10 + unit + 1 
  FROM	( VALUES( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)) AS Units( unit ) 
	CROSS JOIN 
	( VALUES( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)) AS Tens( ten )
	CROSS JOIN
	( VALUES( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)) AS Hundreds( hundred );

but I am getting:

 ?column?
----------
        1
(1 row)

which isn't close to the 1000 rows that I am expecting.  

Is Mr. Celko mistaken?  Does anyone know if PostgreSQL has any functions that I can turn these
VALUES rows into columns so that the CROSS JOINS will work?   

Regards,
Richard Broersma Jr.



view thread (2+ messages)  latest in thread

Message-ID: <649296.88043.qm@web31815.mail.mud.yahoo.com>
Permalink:  ../649296.88043.qm@web31815.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/649296.88043.qm@web31815.mail.mud.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rabroersma@yahoo.com
  Subject: Re: Joe Celko's method to "generate_series" not working?
  In-Reply-To: <649296.88043.qm@web31815.mail.mud.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox