Reputation: 61
I want to run a query that will return 'Yes' when the distinct count and count return the same value. Below is the unsuccessful query.
SELECT
DISTINCT(COUNT(colA)),
COUNT(colA),
CASE
WHEN DISTINCT(COUNT(colA)) = COUNT(colA) THEN 'Yes'
ELSE 'Sad'
END
FROM tableA
Upvotes: 2
Views: 195
Reputation: 24603
you need to count distinct like so :
SELECT
COUNT(DISTINCT colA),
COUNT(colA),
CASE WHEN COUNT(DISTINCT colA) = COUNT(colA) THEN 'Yes' ELSE 'Sad' END
FROM tableA
Upvotes: 4