In today’s article, we will be learning the GROUP BY command, which allows us to perform operations by grouping columns.
GROUP BY also has functions such as sum() and count().
I will do the examples in this article using the address table in the pagila database.
You can use the link below to download the Pagila database.
1 |
https://dbtut.com/index.php/2018/10/28/how-to-install-postgresql-sample-database/ |
We will list how many records are in the same district using the Address table.
1 2 3 |
SELECT count(district),district FROM address GROUP BY district |