pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: pgsql-sql@postgresql.org
Subject: Another date range join problem
Date: Thu, 5 Apr 2007 16:17:58 +0100
Message-ID: <200704051617.59022.gary.stainburn@ringways.co.uk> (raw)

Hi folks, me again.

I'm back with my availability and roster tables again.

I have:

Table "public.availability"
  Column   |            Type        
-----------+------------------------
 aid       | serial primary key
 asid      | integer                
 asdate    | date                   
 afdate    | date                   

      Table "public.roster_staff"
   Column    |  Type   |   Modifiers
-------------+---------+---------------
 rsdate      | date    | not null
 rsgid       | integer |
 rsgsid      | integer |
 rssid       | integer |


I want to do a join giving the details from the availability with a count of 
roster_staff records within the range asdate->afdate for each staff member 
(asid <-> rssid)

e.g.
availability

1	1	2007-04-01	2007-04-01
2	1	2007-04-10	2007-04-15

roster_staff

2007-04-01	4	5	1
2007-04-11	4	6	1
2007-04-13	4	3	1
2007-04-14	5	5	1
2007-04-15	5	6	1

giving

1	1	2007-04-01	2007-04-01	1
2	1	2007-04-10	2007-04-15	4

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     



Message-ID: <200704051617.59022.gary.stainburn@ringways.co.uk>
Permalink:  ../200704051617.59022.gary.stainburn@ringways.co.uk/
Also on:    postgresql.org/message-id/200704051617.59022.gary.stainburn@ringways.co.uk

 · 

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: gary.stainburn@ringways.co.uk
  Subject: Re: Another date range join problem
  In-Reply-To: <200704051617.59022.gary.stainburn@ringways.co.uk>

* 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