4 Advanced aggregation and analysis of data
This chapter covers
- Preparing, cleaning and aggregating data while ingesting
- Using window functions to create new aggregates over different partitions of any dataset
- Understanding the different types of sub-queries
- Using Common Table Expressions (CTEs)
- Applying filters to any aggregate
The goal of this chapter is to give you some ideas on how an analytical database such as DuckDB can be used to provide reports that would take a considerably larger amount of code written in an imperative programming language. While we will build upon the foundation laid in chapter 3, we will leave a simple SELECT xzy FROM abc
behind quickly. Investing your time in learning modern SQL won’t be wasted. The constructs presented here can be used everywhere where DuckDB can be run or embedded and therefore enrich your application.