Reputation: 1
I am using the below query to get distinct records from 4 specific columns in an sql DB.
SELECT DISTINCT customer,
product,
category,
sector
FROM data_table
I need to add the count of products in this query. Any ideas?
Upvotes: 0
Views: 42
Reputation: 32011
are you find something below
select count(*) from
(SELECT DISTINCT customer, product, category, sector
FROM data_table
) a
or do you need window function count() if your dbms support
SELECT DISTINCT customer, product, category, sector,
count(*) over() as cnt
FROM data_table
Upvotes: 2