Re: query help - count

From: www.douglassdavis.com <douglass_davis_at_earthlink.net>
Date: Fri, 10 Oct 2008 06:24:46 -0700 (PDT)
Message-ID: <aa333735-f3a0-4912-930e-186919dc235d@v28g2000hsv.googlegroups.com>


On Oct 9, 11:44 pm, "Michel Cadot" <micadot{at}altern{dot}org> wrote:
> "Jake" <jgarfi..._at_earthlink.net> a écrit dans le message de news:
> 57df32d6-8ba6-446b-a372-815a41ff7..._at_t54g2000hsg.googlegroups.com...
> Sorry, I need to change how that is set up. Ignore previous post.
>
> it would be more like
>
>  table1
>  person_type
>  person_id
>
>  table2
>  person_id
>  appt_date
>
> and again...  There is a one to many relationship between table 1 and
> table 2.
>
>  where
>
>  table1.person_id=table2.person_id
>
>  I would like to get a count of unique people in table1 for each
>  appt_date in table2. Keep in mind that each person may have more
> than
>  one appt in a single day.
>
> Here's the twist though, there is a condition on table one. say
> person_type=2.  So, say I only want to get counts of the unique number
> of people on each day, but they only count when person_type=2.
>
> And, the results should be rows of:
>  appt_date, count
>  appt_date, count
>
> How would i do that? Thanks.
>
> ------------------------------------------------
>
> What about using COUNT on the join?
> Actually where is your problem on this query?
> Is this in "Keep in mind that each person may have more
> than one appt in a single day"? Just count DISTINCT person_id.
>
> Regards
> Michel

You're right, a count distinct and group by worked. Thought I had tried that before but I must have done something wrong. Received on Fri Oct 10 2008 - 08:24:46 CDT

Original text of this message