Re: Joe Celko's method to "generate_series" not working?

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>, SQL Postgresql List <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Joe Celko's method to "generate_series" not working?
Date: 2007-05-03 00:35:02
Message-ID: 105002.73150.qm@web31808.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


--- Richard Broersma Jr <rabroersma(at)yahoo(dot)com> wrote:

> 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?

Having posted, I just realized what the correct syntax is:

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 )
ORDER BY hundred * 100 + ten * 10 + unit + 1 ;

Sorry for the noise. :o(

Regards,
Richard Broersma Jr.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Penchalaiah P. 2007-05-03 04:38:21 Needs Function
Previous Message Richard Broersma Jr 2007-05-03 00:17:07 Joe Celko's method to "generate_series" not working?