Re: distinct in a group by Date
On 19 Oct, 01:14, sparky <markdueck...@gmail.com> wrote:
> On Oct 18, 3:25 pm, "Paul Lautman" <paul.laut...@btinternet.com>
> wrote:
>
>
>
>
>
> > sparky wrote:
> > > I have the following view, and would like to do a group by date to
> > > find out what is the current size of production. I can do the group
> > > by week (dt), but that returns 1 barn 7 times per week, so it sums it
> > > up 7 times. How can I do this group by and use the distinct to have
> > > only one barn per grouping?
>
> > > ID Barn_ID Size StartDate Received StartDate_p_Life dt
> > > 1 1 5000 08/02/2007 1 22/10/2007 10/18/2007
> > > 5 2 4000 17/10/2007 1 12/08/2008 10/18/2007
> > > 6 3 6000 15/05/2007 1 11/11/2007 10/18/2007
> > > 1 1 5000 08/02/2007 1 22/10/2007 10/19/2007
> > > 5 2 4000 17/10/2007 1 12/08/2008 10/19/2007
> > > 6 3 6000 15/05/2007 1 11/11/2007 10/19/2007
> > > 1 1 5000 08/02/2007 1 22/10/2007 10/20/2007
> > > 5 2 4000 17/10/2007 1 12/08/2008 10/20/2007
> > > 6 3 6000 15/05/2007 1 11/11/2007 10/20/2007
>
> > > maybe it's not even possible to use the distint - I can't quite figure
> > > it out.
>
> > Your description isn't that clear. Can you give a sample of your required
> > output from the above data.
>
> What I want to get is a sum of hens that for each day if I group by
> day, which in this case is no problem. But when I group by week, I
> have barn #1 listed each day, so if you just do a simple group by per
> week, it adds up barn #1 seven times, but I only want it once. The
> same goes for month. I guess I could do a where clause and set it to
> retrieve only the first day of the week, and then the grouping should
> work, right? How can I only the first day of the week?
> Thanks- Hide quoted text -
>
> - Show quoted text -
Which part of "Can you give a sample of your required output from the
above data." was it that you didn't understand?
|