Re: Aggregate function, Grouping
- From: "Michael Jacobs" <iq193@xxxxxxxxxxxxx>
- Date: Fri, 19 May 2006 07:10:36 -0400
Kim,
The 'group by' clause references 'bl.BU_KEY' but that field isn't
included in the 'select' clause.
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
.
- Follow-Ups:
- Re: Aggregate function, Grouping
- From: Kim S
- Re: Aggregate function, Grouping
- References:
- Aggregate function, Grouping
- From: Kim S
- Aggregate function, Grouping
- Prev by Date: Aggregate function, Grouping
- Next by Date: Re: Aggregate function, Grouping
- Previous by thread: Aggregate function, Grouping
- Next by thread: Re: Aggregate function, Grouping
- Index(es):
Relevant Pages
|