You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Manoj Bharadwaj <ma...@gmail.com> on 2014/09/12 20:25:48 UTC

Count (Distinct Case When...)

Hello World!

I'm not able to do the below in Hive. Is this a limitation?

*Count (Distinct Case When Col2 is not null then Col1 else End) as Count1*

This give me the same result as:
*Count (Distinct Col1) as Count2*

NB: There are significant cases where *Col2* is null

I couldn't find any support on the web for this - hence the question to the
group. Links/reading material appreciated

Thanks!
Manoj

Re: Count (Distinct Case When...)

Posted by Nitin Pawar <ni...@gmail.com>.
you may want to do it with where condition

count(distinct col1) as count 1 where col2 is not null

On Fri, Sep 12, 2014 at 11:55 PM, Manoj Bharadwaj <manoj.bharadwaj@gmail.com
> wrote:

> Hello World!
>
> I'm not able to do the below in Hive. Is this a limitation?
>
> *Count (Distinct Case When Col2 is not null then Col1 else End) as Count1*
>
> This give me the same result as:
> *Count (Distinct Col1) as Count2*
>
> NB: There are significant cases where *Col2* is null
>
> I couldn't find any support on the web for this - hence the question to
> the group. Links/reading material appreciated
>
> Thanks!
> Manoj
>



-- 
Nitin Pawar