Home

10: Selecting Distinct Records

DISTINCT is always placed with a SELECT statement.

It will give us unique values in our result set.

Example:

SELECT DISTINCT department FROM products;

A good use of this is to COUNT the unique values over one column.

You can use GROUP BY in place of DISTINCT but you cannot use DISTINCT in place of GROUP BY.

Repository

https://github.com/okeeffed/developer-notes-nextjs/content/postgresql/SQL-And-PostgreSQL-The-Complete-Developers-Guide/10-Selecting-Distinct-Records

Sections


Related