Re: Aggregate function, Grouping
- From: Kim S <ks@xxxxxxxxxxxxxxx>
- Date: Fri, 19 May 2006 13:22:46 +0200
Ok, thanks, I understand.
BUT, the grouping problem I have first occurs when I include the fields
bl.UseClientAmount, bl.Amount, bl.ClientAmount
in the Group By part. I don't want these fields there, can I avoid them?
Michael Jacobs wrote:
Since the 'having' clause selects on the 'bl.bu_key' and it will be a specific value you can either include it in the 'select' clause or remove it from the 'group by'.
hth,
Michael
"Kim S" <ks@xxxxxxxxxxxxxxx> wrote in message news:446d9ea3$1@xxxxxxxxxxxxxxxxxxxxxxxxx
When I try to execute the sql statement:
SELECT
bl.GR_KEY, bl.GroupOrder, bl.UseOverhead,
SUM (Amount * price) as "SubTotal",
IIF (bl.UseClientAmount = True,
bl.Amount + bl.ClientAmount,
bl.Amount) as "RealAmount"
FROM
Budget_Lines bl
GROUP BY
bl.BU_KEY, bl.GroupOrder, bl.UseOverhead, bl.GR_KEY
HAVING
bl.BU_KEY = :BU_KEY
I get an exception, because the Group By fields do not match the Select fields.
But if I include the fields:
GROUP BY
bl.BU_KEY, bl.GroupOrder, bl.UseOverhead, bl.GR_KEY,
bl.UseClientAmount, bl.Amount, bl.ClientAmount
- the result is wrongly grouped. Can I avoid this problem?
Regards,
Kim
- References:
- Aggregate function, Grouping
- From: Kim S
- Re: Aggregate function, Grouping
- From: Michael Jacobs
- Aggregate function, Grouping
- Prev by Date: Re: Aggregate function, Grouping
- Next by Date: Re: Aggregate function, Grouping
- Previous by thread: Re: Aggregate function, Grouping
- Next by thread: Re: Aggregate function, Grouping
- Index(es):