0
votes

My impala table is as below.

Column1 Column2 Column3 Column4
Abc     1       A       desc1
Abc     1       A       desc2 
Abc     1       A       desc3 
Abc     1       A       desc4
Abc     1       B       dwsc1
Abc     1       B       dwsc2
Xyz     1       A       desc1

I would like to find out the count of distinct column values in column3 for each combination of column1 and column2.

For example. For combination of Abc and 1 I have 2 values in column3 - A and B. For Xyz and 1 I have only one.

Expected output:

Column1 Column2 count(column3)
Abc     1       2     
Xyz     1       1

How to achieve this in impala ?

1

1 Answers

3
votes

use distinct count

select column1,column2, count(distinct column3)
from table
group by column1,column2