Count distinct value pairs in multiple columns in SQL
Get all distinct id
, name
and address
columns and count the resulting rows.
SELECT COUNT(*) FROM mytable GROUP BY id, name, address
To get a count of the number of unique combinations of id
, name
and address
:
SELECT Count(*)
FROM (
SELECT DISTINCT
id
, name
, address
FROM your_table
) As distinctified