# Any demo/code/best-practice about downsampling

**URL:** <https://community.cratedb.com/t/any-demo-code-best-practice-about-downsampling/199>\
**Category:** Documentation\
**Created:** [May 11, 2019, 2:55am UTC](https://community.cratedb.com/t/any-demo-code-best-practice-about-downsampling/199 "2019-05-11T02:55:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hankersyan](https://avatars.discourse-cdn.com/v4/letter/h/41988e/32.png) [@hankersyan](https://community.cratedb.com/u/hankersyan)\
**Post date:** [May 11, 2019, 2:55am UTC](https://community.cratedb.com/t/any-demo-code-best-practice-about-downsampling/199/1 "2019-05-11T02:55:40Z")

</div>

I can not find any official demo/sample-code/best-practice about time series downsampling for cratedb from google, github or [crate.io](http://crate.io), especially for IOT data. Could anyone help, Thanks!

---

<div class="post-metadata">

**Author:** ![simonfey](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/simonfey/32/147_2.png) [@simonfey](https://community.cratedb.com/u/simonfey)\
**Post date:** [January 29, 2020, 9:22am UTC](https://community.cratedb.com/t/any-demo-code-best-practice-about-downsampling/199/2 "2020-01-29T09:22:55Z")

</div>

try date\_trunc.

> <https://stackoverflow.com/questions/26465077/resample-on-time-series-data>

---

<div class="post-metadata">

**Author:** ![hernanc](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/hernanc/32/676_2.png) [@hernanc](https://community.cratedb.com/u/hernanc)\
**Post date:** [October 28, 2022, 3:33pm UTC](https://community.cratedb.com/t/any-demo-code-best-practice-about-downsampling/199/3 "2022-10-28T15:33:36Z")

</div>

Hi, I realise it has been a while since this question was posted, but I thought of writting this here in case someone could find it useful.  
We have a short tutorial on this topic [Resampling time-series data with DATE\_BIN - Tutorials - CrateDB Community](https://community.cratedb.com/t/resampling-time-series-data-with-date-bin/1009).  
Once old data has been resampled, we can either:

- [delete it](https://community.cratedb.com/t/cratedb-and-apache-airflow-implementation-of-a-data-retention-policy/913)
- [back it up and then delete it](https://community.cratedb.com/t/cratedb-and-apache-airflow-building-a-data-retention-policy-using-external-snapshot-repositories/1001)
- [move it to cheaper storage](https://community.cratedb.com/t/cratedb-and-apache-airflow-building-a-hot-cold-storage-data-retention-policy/934)
