# Counting, Grouping and Paging

COUNT, SUM and AVG let the database add up rows instead of sending every one to Python, GROUP BY gives one answer for each vendor, and LIMIT with OFFSET hands an API one page of a long list at a time, with COUNT(\*) giving the total beside it.

![Cheat sheet: Counting, Grouping and Paging](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/0a87421be3cd4b6d9c5656737ef05b01.webp)

- Category: FastAPI
- Level: Journeyman
- Tags: Aggregate Function, COUNT, database, group by, having, OFFSET Clause, Pagination, sql, sqlite
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/fastapi-sql-counting-and-paging-cheat-sheet
