Re: create a 'range' of dates/numbers?

From: Erwin Moller <erwin(at)darwine(dot)nl>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: create a 'range' of dates/numbers?
Date: 2008-12-19 10:43:53
Message-ID: 494B7AE9.6070903@darwine.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

A. Kretschmer schreef:
> In response to Erwin Moller :
>
>> Hi,
>>
>> Is it possible to create a range of dates or numbers inside a query
>> without wrining in procedural language?
>> I am looking for something that creates some kind of 'temp table' inside
>> a query.
>> eg:
>>
>
> generate_Series():
>
> test=# select * from generate_Series(1,5);
> generate_series
> -----------------
> 1
> 2
> 3
> 4
> 5
> (5 rows)
>
> test=*# select current_date + s * '1day'::interval from
> generate_Series(1,5)s;
> ?column?
> ---------------------
> 2008-12-20 00:00:00
> 2008-12-21 00:00:00
> 2008-12-22 00:00:00
> 2008-12-23 00:00:00
> 2008-12-24 00:00:00
> (5 rows)
>
>
> Andreas
>
Wow, you ARE fast. :-)

Thanks a lot all, excactly what I was looking for!

Regards,
Erwin Moller

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Reg Me Please 2008-12-19 11:04:22 [PGSQL 8.3.5] How to handle FKs with partitioning?
Previous Message Thomas Markus 2008-12-19 10:43:22 Re: create a 'range' of dates/numbers?