This chapter is about how to aggregate and sample data in HQL. It first covers the use of several aggregate functions, enhanced aggregate functions, and window functions working with a GROUP BY, PARTITION BY statement. Then, it introduces the different ways of sampling data. In this chapter, we will cover the following topics: