Sum and Compare columns in Hive?
<p>This may be really nothing but as i am new to hive. I don't know how to do this in Hive?</p>

<p>I have a sample dataset that looks like this:</p>

<pre><code>    column_A       column_B    column_C
       1             1          0
       1             1          0
       1             0          1
</code></pre>

<p>Now, i need to find out the sum of each column and then compare them to get the highest.</p>

<p>for example:</p>

<pre><code> column_A       column_B    column_C
    3              2            1
</code></pre>

<p>Output should be:</p>

<pre><code>  column_A   
     3  
</code></pre>

<p>Query that I wrote is unable to perform the sum of  each columns and compare columns to find the greatest among them.</p>

<pre><code>SELECT (sum(column_A) as A,sum(column_B) as B,sum(column_C) as C) as xyz
from table_name where A IN (SELECT GREATEST(A,B,C) from xyz) ;
</code></pre>