07-31-2023, 09:45 AM
This query helps me (in MSSQL) find the unique count with more than one column.
SELECT COUNT(DISTINCT concat_column) AS unique_count
FROM (
SELECT CONCAT(column1, '|', column2, '|', column3) AS concat_column
FROM your_table_name_here
) AS subquery;
SELECT COUNT(DISTINCT concat_column) AS unique_count
FROM (
SELECT CONCAT(column1, '|', column2, '|', column3) AS concat_column
FROM your_table_name_here
) AS subquery;