Please forgive me I am struggling for the correct term on what i'm trying to achieve.
I have a query result of responses and I'm trying to just have the count on the unique value in the adjacent column. COUNT(...) and COUNT(DISTINCT ...) are not giving me what I require.
date total_responses responseType generationNumber
20-01-22 53 positive 125
20-01-22 7 negative 125
15-01-22 73 positive 70
15-01-22 112 negative 70
07-01-22 126 positive 15
07-01-22 121 negative 15
03-01-22 74 positive 1
03-01-22 2 negative 1
As you can hopefully see I aiming to count the unique values in generationNumber.
My SELECT statement:
SELECT MIN(a.[date]) AS 'date', COUNT(a.employee) AS 'total_responses', a.responseType , b.GenerationNumber
My desired outcome:
date total_responses responseType generationNumber unique_count
20-01-22 53 positive 125 4
20-01-22 7 negative 125 4
15-01-22 73 positive 70 3
15-01-22 112 negative 70 3
07-01-22 126 positive 15 2
07-01-22 121 negative 15 2
03-01-22 74 positive 1 1
03-01-22 2 negative 1 1