# Multiple Aggregations Problems

**URL:** <https://forum.servoy.com/t/multiple-aggregations-problems/9229>\
**Category:** Classic Servoy\
**Created:** [June 26, 2008, 10:32am UTC](https://forum.servoy.com/t/multiple-aggregations-problems/9229 "2008-06-26T10:32:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![prj311](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@prj311](https://forum.servoy.com/u/prj311)\
**Post date:** [June 26, 2008, 10:32am UTC](https://forum.servoy.com/t/multiple-aggregations-problems/9229/1 "2008-06-26T10:32:51Z")

</div>

Hi All,  
I am not sure if this is a bug in servoy or I am doing something wrong, but I have the following problem.

I have a parent orders form with a portal showing related records, each related record has a simple calculation field eg. **return qty\*cost** then I have a sum aggregation of that calculation field displayed on the parent form through a relationship **eg orders.line\_items.sumTotal** , every thing works as expected until a second aggregation is added in the line\_items table.eg sumTotal, countTotal then the aggregation no longer updates.

below are the sql statements from performance log

**With 2 aggregates example**

```auto
00:00:000 1 00:00:000 Update update line_items set cost=?, sub_total=? where line_item_id = ?

```

**With 1 aggregate example**

```auto
00:00:000	1	00:00:000	Aggregate SQL	select sum(sub_total) as lineTotal from line_items where orders_id = ? limit ?
00:00:000	1	00:00:000	Update	update line_items set qty=?, sub_total=? where line_item_id = ?

```

The second example works as expected.

I am using  
Servoy Developer  
Version 3.5.6-build 519  
Java version 10.0-b19 (Windows XP)

I have attached a simple solution.

[aggregates.servoy](https://forum.servoy.com/uploads/short-url/rN9Y4Bl1dFvcHLP1m0bJPSB12kl.servoy) (5.55 KB)

---

<div class="post-metadata">

**Author:** ![prj311](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@prj311](https://forum.servoy.com/u/prj311)\
**Post date:** [June 26, 2008, 12:53pm UTC](https://forum.servoy.com/t/multiple-aggregations-problems/9229/2 "2008-06-26T12:53:57Z")

</div>

OK,  
I just noticed that if I display the second related aggregate field on the parent (Orders) form both update with the correct value … That seems strange. Help Please

---

<div class="post-metadata">

**Author:** ![prj311](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@prj311](https://forum.servoy.com/u/prj311)\
**Post date:** [June 27, 2008, 12:29pm UTC](https://forum.servoy.com/t/multiple-aggregations-problems/9229/3 "2008-06-27T12:29:41Z")

</div>

H’mm,  
Am I along with this problem??

---

<div class="post-metadata">

**Author:** ![lvostinar](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/lvostinar/32/5248_2.png) [@lvostinar](https://forum.servoy.com/u/lvostinar)\
**Post date:** [June 27, 2008, 2:18pm UTC](https://forum.servoy.com/t/multiple-aggregations-problems/9229/4 "2008-06-27T14:18:11Z")

</div>

Hi,

I guess you posted here the solution that is working, right ? I added a second aggregation on line\_items which is a count for sub\_total column. Then I displayed this aggregation both on portal and main form and it works well . Do you use other aggregation as the second one ? Do you have any errors in the log ?

---

<div class="post-metadata">

**Author:** ![prj311](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@prj311](https://forum.servoy.com/u/prj311)\
**Post date:** [June 27, 2008, 10:59pm UTC](https://forum.servoy.com/t/multiple-aggregations-problems/9229/5 "2008-06-27T22:59:14Z")

</div>

Hi,  
Thanks for the reply,

the problem seems to be when you **do not** display the second aggregate on the parent form.

> OK,  
> I just noticed that if I display the second related aggregate field on the parent (Orders) form both update with the correct value … That seems strange. Help Please

I have attached a new sample solution to demonstrate the problem in a clearer way.

[aggregates.servoy](https://forum.servoy.com/uploads/short-url/zM0zdN4qiO3E715LWQFPSXknMaW.servoy) (9.44 KB)

---

<div class="post-metadata">

**Author:** ![lvostinar](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/lvostinar/32/5248_2.png) [@lvostinar](https://forum.servoy.com/u/lvostinar)\
**Post date:** [June 30, 2008, 8:15am UTC](https://forum.servoy.com/t/multiple-aggregations-problems/9229/6 "2008-06-30T08:15:20Z")

</div>

Hi,

I checked your solution and it seems to be a bug. Please submit an issue to [http://crm.servoy.com/servoy-webclient/ … oy\_support](http://crm.servoy.com/servoy-webclient/solutions/solution/servoy_support) and link to this topic. I noticed this only happens when having an aggregation on stored calculation ( so if a column works well); also the ‘average’ aggregation works well, this is why the last example works, that aggregation updates its value so all the others will be refreshed as well. Maybe this will help to get a workaround until the problem will be fixed.
