# Understand GROUP BY in Django ORM with SQL

DevFeed: [Understand GROUP BY in Django ORM with SQL](<https://devfeed.tech/articles/understand-group-by-in-django-with-sql-33896.md>)

Original publisher: [Read original article](<https://hakibenita.com/django-group-by-sql>)

Author: Haki Benita

Published: 2020-02-10T22:00:00Z

Content type: tutorial

Language: en

Sources: [Haki Benita](<https://devfeed.tech/sources/haki-benita.md>)

Topics: [Django](<https://devfeed.tech/topics/django.md>), [Object-relational mapping](<https://devfeed.tech/topics/orm.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [Tutorial](<https://devfeed.tech/topics/tutorial.md>)

Tags: [aggregate](<https://devfeed.tech/tags/aggregate.md>), [articles](<https://devfeed.tech/tags/articles.md>), [count](<https://devfeed.tech/tags/count.md>), [django](<https://devfeed.tech/tags/django.md>), [filter](<https://devfeed.tech/tags/filter.md>), [orm](<https://devfeed.tech/tags/orm.md>), [sort](<https://devfeed.tech/tags/sort.md>), [sql](<https://devfeed.tech/tags/sql.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

## AI overview

A tutorial explains Django ORM aggregation by comparing QuerySets with equivalent SQL GROUP BY queries. It covers counting rows, handling NULL values, grouping by fields, filtering, sorting, and multiple aggregations.

## Source excerpt

Understand GROUP BY in Django ORM by comparing QuerySets and SQL side by side. If SQL is where you are most comfortable, this is the Django GROUP BY tutorial for you.