Re: Query to Find Members of a Group at a Point in Time
- From: Bob Quintal <rquintal@xxxxxxxxxxxxx>
- Date: Wed, 28 Jan 2009 23:05:36 GMT
GM7 <arkins@xxxxxxxxx> wrote in
news:cbe6c674-3255-4d83-a74d-9d7d344c0067
@v13g2000yqm.googlegroups.co
m:
Thanks Bob, I'll give that a try.
Is the third query a Union query?
no not a union query, a simple left join type
SELECT Query1.Group,
Query1.MemberName,
Query1.InDate,
NZ(Query2.OutDate, date()) as OutDate
from Query1
LEFT JOIN Query2
ON query1.Group = Query2.Group
AND Query1.Membername = Query2.MemberName
WHERE DateInQuestion Between Query1.InDate AND Query2.Outdate
The NZ is for when there is no out record for a particular member.
Define DateInQuestion as your filter parameter in the query
properties.
Hope that helps.
Q
I'm not sure how I would join the in date to the out date in the
third query, as they would be different dates...
On Jan 27, 8:04 pm, Bob Quintal <rquin...@xxxxxxxxxxxxx> wrote:
GM7 <ark...@xxxxxxxxx> wrote in news:abc1f2b1-e16f-4220-b56b-
e106dc15a...@xxxxxxxxxxxxxxxxxxxxxxxxxxx:
All,
I have inherited a DB with a single table showing:
MemberName |Group |EmailDate|Status, e.g:
FredFlintstone|WaterBuffaloes|01/01/2001|In
FredFlintstone|WaterBuffaloes|02/01/2001|In
FredFlintstone|WaterBuffaloes|03/01/2001|Out
FredFlintstone|WaterBuffaloes|04/01/2001|In
BarneyRubble|WaterBuffaloes|01/01/2001|In
BarneyRubble|WaterBuffaloes|02/01/2001|In
BarneyRubble|WaterBuffaloes|03/01/2001|In
BarneyRubble|WaterBuffaloes|04/01/2001|Out
Assume (ha!) I have all records of when people were in or out
of a group.
I want to write a query that will tell me who was in the Group
"WaterBuffaloes" on 03/15/2001.
Is that possible, given my data set?
Can anyone point me in the right direction?
Thanks
Patrick
First you want to create a pair of queries, one with the earliest
in date for each person, group and another with the person, group
and out date. if a member has multiple in-out pairs it's harder
but not impossible.
Then you create a third query that joins the in date to the out
date, based on the relation between name and group
Finally create a fourth query that filters the third for yourdate
Between indate and outdate.
SQL for the first is
SELECT Group, membername, min(emaildate) as InDate
From table GROUP BY Group, Membername
if you need more, post a followup to this message.
--
Bob Quintal
PA is y I've altered my email address.- Hide quoted text -
- Show quoted text -
--
Bob Quintal
PA is y I've altered my email address.
.
- References:
- Prev by Date: Re: Query to Find Members of a Group at a Point in Time
- Next by Date: Re: Filter report by input box
- Previous by thread: Re: Query to Find Members of a Group at a Point in Time
- Next by thread: Form Coordinates
- Index(es):
Relevant Pages
|