PostgreSQL – Count distinct over multiple columns

Sql statement to get the count of distinct values in a column:

SELECT COUNT (DISTINCT col1) FROM table1;

Below is the sql query to get the count of distinct rows over multiple columns.

SELECT COUNT(*) FROM (SELECT DISTINCT col1, col2, col3 FROM table1) AS temp;
See also  PostgreSQL - OFFSET Clause