# Aggregation Query

**URL:** <https://community.cratedb.com/t/aggregation-query/80>\
**Category:** SQL\
**Created:** [December 5, 2018, 8:38am UTC](https://community.cratedb.com/t/aggregation-query/80 "2018-12-05T08:38:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![roman](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/roman/32/36_2.png) [@roman](https://community.cratedb.com/u/roman)\
**Post date:** [December 5, 2018, 8:38am UTC](https://community.cratedb.com/t/aggregation-query/80/1 "2018-12-05T08:38:38Z")

</div>

Hi All, iam doing a aggregation query insert into another table. Now when the id is duplicate i set the value to overwrite with:

on conflict (id) do update set  
val\_average = val\_average,  
val\_count = val\_count,  
val\_max = val\_max,  
val\_min = val\_min,  
val\_sum = val\_sum;

Hi All, iam doing a aggregation query insert into another table. Now when the id is duplicate i set the value to overwrite with:

```auto
     val_average = val_average,
     val_count = val_count,
     val_max = val_max,
     val_min = val_min,
     val_sum = val_sum;

```

The create date shows the row should be updated. but the actual value is not. Do you have an idea why this is?

or do i need to use?

````auto
     val_average = val_average,
     val_count = excluded.val_count,
     val_max = excluded.val_max,
     val_min = excluded.val_min,
     val_sum = excluded.val_sum;```
````
