# Data aggregation using continuous queries

**URL:** <https://community.influxdata.com/t/data-aggregation-using-continuous-queries/6970>\
**Category:** Systems\
**Created:** [October 10, 2018, 7:44am UTC](https://community.influxdata.com/t/data-aggregation-using-continuous-queries/6970 "2018-10-10T07:44:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hemuangel17](https://avatars.discourse-cdn.com/v4/letter/h/9de0a6/32.png) [@hemuangel17](https://community.influxdata.com/u/hemuangel17)\
**Post date:** [October 10, 2018, 7:44am UTC](https://community.influxdata.com/t/data-aggregation-using-continuous-queries/6970/1 "2018-10-10T07:44:42Z")

</div>

I’m new to Influx db . We are ingesting data from Talend to influxdb and passing to grafana .

Can you throw some idea on how to create aggregated data metrics using continuous query

. For example  
• #Orders breaching SLA in last 1 hr/1day or 1 month  
• #Orders inserted into the system in last 1 hr/1day or 1 month

---

<div class="post-metadata">

**Author:** ![katy](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/katy/32/855_2.png) [@katy](https://community.influxdata.com/u/katy)\
**Post date:** [October 11, 2018, 3:44pm UTC](https://community.influxdata.com/t/data-aggregation-using-continuous-queries/6970/2 "2018-10-11T15:44:22Z")

</div>

Does this [doc](https://docs.influxdata.com/influxdb/v1.6/guides/downsampling_and_retention/) do what you need? It walks through how to downsample with your continuous queries.

---

<div class="post-metadata">

**Author:** ![hemuangel17](https://avatars.discourse-cdn.com/v4/letter/h/9de0a6/32.png) [@hemuangel17](https://community.influxdata.com/u/hemuangel17)\
**Post date:** [October 12, 2018, 5:44am UTC](https://community.influxdata.com/t/data-aggregation-using-continuous-queries/6970/3 "2018-10-12T05:44:00Z")

</div>

Hi Katy,

Thanks for your reply !!

However i have not got the expected result using the samples given in the doc

---

<div class="post-metadata">

**Author:** ![hemuangel17](https://avatars.discourse-cdn.com/v4/letter/h/9de0a6/32.png) [@hemuangel17](https://community.influxdata.com/u/hemuangel17)\
**Post date:** [October 12, 2018, 5:54am UTC](https://community.influxdata.com/t/data-aggregation-using-continuous-queries/6970/4 "2018-10-12T05:54:28Z")

</div>

> show databases  
> name: databases  
> \_internal  
> Testing  
> slamgmt  
> mydbdemo  
> food\_data  
> use food\_data  
> Using database food\_data  
> show measurements  
> name: measurements  
> name

* * *

downsampled\_orders  
orderscq  
ordersnew

> select \* from orderscq  
> name: orderscq  
> time phone websit

* * *

1539070565215754500 10 30  
1539070575140554500 12 39  
1539070592247154500 11 56

Show continuous queries

name: food\_data  
name query

* * *

cq\_15m CREATE CONTINUOUS QUERY cq\_15m ON food\_data BEGIN SELECT mean(website) AS mean\_website, mean(phone) AS mean\_phone INTO food\_data.a\_year.downsampled\_order  
s FROM food\_data.autogen.orderscq GROUP BY time(15m) END

cq\_10m CREATE CONTINUOUS QUERY cq\_10m ON food\_data BEGIN SELECT mean(website) AS mean\_website, mean(phone) AS mean\_phone INTO food\_data.a\_year.downsampled\_order  
s FROM food\_data.autogen.ordersnew GROUP BY time(10m) END

> 

> Select \* from food\_data.a\_year.downsampled\_orders  
> name: downsampled\_orders  
> time mean\_website

* * *

1539070200000000000 41.666666666666664  
1539076200000000000 43

> 

Issues in above continuous query is " I’m not able to find the mean\_phone list on the new measurement

Let me know ur thoughts
