From: | Ragnar Hafstað <gnari(at)simnet(dot)is> |
---|---|
To: | Yudie Pg <yudiepg(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to join function with a table? |
Date: | 2005-08-05 21:36:49 |
Message-ID: | 1123277809.8191.6.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 2005-08-05 at 10:53 -0500, Yudie Pg wrote:
> Hi everyone,
>
> I have a function returning set of date called datelist(date,date)
> example:
> select * from datelist('8/1/2005, 8/5/2005');
> 8/1/2005
> 8/2/3005
> 8/3/2004
> 8/4/2005
> 8/5/2005
>
> I would like to join this function with a table
> create table payment(
> id int4 not null,
> date_start date,
> date_end date
> )
> id | date_start | date_end
> ----------------------------------------
> 1 | 8/1/2005 | 8/2/2005
> 2 | 8/4/2005 | 8/6/2005
>
> I wish I could do join that returns something like this with the
> function
>
> id | datelist
> ------------------
> 1 | 8/1/2005
> 1 | 8/2/2005
> 2 | 8/4/2005
> 2 | 8/5/2005
> 2 | 8/6/2005
>
what about something like
select id,datelist
from payment as p,
(select * from datelist('8/1/2005, 8/5/2005')) as list
where datelist between p.date_start and p.date_end;
gnari
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2005-08-05 21:53:24 | Re: Clog/Transaction problems |
Previous Message | Yudie Pg | 2005-08-05 20:58:15 | Re: How to join function with a table? |