Subject | Re: Aggregation and selectable SP |
---|---|
Author | Carlos Macao |
Post date | 2005-12-12T12:37:25Z |
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:
Of course it works, I didn't try that because I was still thinking
in the agregation on the subselect, where I could not remove
TOTAL_DAY_SELLING.
Thank you.
<svein.erling.tysvaer@k...> wrote:
Of course it works, I didn't try that because I was still thinking
in the agregation on the subselect, where I could not remove
TOTAL_DAY_SELLING.
Thank you.
> It should group on the combination, if you want to group on WEEK_NOyou
> only, you have to remove SELLING_DATE from the equation, i.e.
>
> select WOY.WEEK_NO WEEK, sum(S.TOTAL_DAY_SELLING)
> from SELLINGS S
> left join WEEK_OF_YEAR(S.TOTAL_DAY_SELLING) WOY ON 1=1
> group by 1
>
> Of course, you could add SELLING_DATE as a aggregate function if
> wanted, e.g. MIN(S.SELLING_DATE).WEEK,
>
> Set
>
> > > --- In firebird-support@yahoogroups.com, "Carlos Macao" wrote:
> > > >
> > > > Hi,
> > > >
> > > > I Want to obtain the selling total amount grouped by week
> > > > number, how can I do this sum on a selectable SP?
> > > >
> > > > With this example, the aggregation is performed on the
> > > > TOTAL_DAY_SELLING instead of the WEEK_NO.
> > > >
> > > > And I would prefer to this with a SP, rather than a UDF, for
> > > > speed and installation reasons.
> > > >
> > > > select
> > > > (select WEEK_NO from WEEK_OF_YEAR(S.TOTAL_DAY_SELLING))
> > > > S.SELLING_DATE,
> > > > sum(S.TOTAL_DAY_SELLING)
> > > > from SELLINGS S
> > > > group by 1, 2
> > > >
> > > > Thanks,
> > > > Carlos Macao
>