Re: SQL Query

From: Jim Lombardi <Jim.Lombardi_at_tfn.com>
Date: 31 Oct 2001 10:53:25 -0800
Message-ID: <10f607d.0110311053.70689746_at_posting.google.com>


"Patrick Pleass" <pat_at_pleass.com.au> wrote in message news:<1wDy7.4649$bE1.22696_at_news1.rdc1.nsw.optushome.com.au>...
> Hi All,
>
> Single table (called activities) with fields day, start_time and duration. I
> want to find the number of distinct day and start_time combinations,
> ignoring the duration.
>
> In MySQL I would execute this:
>
> SELECT count(distinct day,start_time) FROM activities;
>
> Oracle only seems to allow a single field in a count statement. When I use
> count(*), the number returned includes all distinct durations as well.
>
> Can someone suggest a work-around?
>
> Thanks,
>
> Pat

Try an inline view, Pat, as follows:

select count(grp_cnt)
from (select day, start_time, count(*) grp_cnt

      from   activities
      group by day, start_time)

JimL Received on Wed Oct 31 2001 - 19:53:25 CET

Original text of this message