<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Hive - i would like to calculate percentage of column and based on the percentage i would like to load the data into another table in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-i-would-like-to-calculate-percentage-of-column-and/m-p/190679#M65372</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/14949/reddyppr.html" nodeid="14949"&gt;@PPR Reddy&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Here goes the solution (You can do it in other ways if you choose to):&lt;/P&gt;&lt;P&gt;Column name in table a is c&lt;/P&gt;&lt;P&gt;hive&amp;gt; select * from a;&lt;/P&gt;&lt;P&gt;OK&lt;/P&gt;&lt;P&gt;y&lt;/P&gt;&lt;P&gt;y&lt;/P&gt;&lt;P&gt;y&lt;/P&gt;&lt;P&gt;n&lt;/P&gt;&lt;P&gt;hive&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Query:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;hive&amp;gt; select c,per from(  &amp;gt; select x.c c,(x.cc/y.ct)*100 per,(z.cn/y.ct)*100 pern  from  &amp;gt; (select c, count(*) cc from a group by c) x, (select count(*)ct from a) y,  &amp;gt; (select c, count(*) cn from a where c='n' group by c) z) f  &amp;gt; where pern &amp;gt; 20;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Output:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;OK&lt;/P&gt;&lt;P&gt;n 25.0&lt;/P&gt;&lt;P&gt;y 75.0&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Sat, 22 Jul 2017 03:59:21 GMT</pubDate>
    <dc:creator>rbiswas1</dc:creator>
    <dc:date>2017-07-22T03:59:21Z</dc:date>
    <item>
      <title>Hive - i would like to calculate percentage of column and based on the percentage i would like to load the data into another table</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-i-would-like-to-calculate-percentage-of-column-and/m-p/190678#M65371</link>
      <description>&lt;P&gt;Hive - i would like to calculate percentage of column and based on the percentage i would like to load the data into another table(if the percentage of n is less 20%) or else not to load&lt;/P&gt;&lt;P&gt;colA &lt;/P&gt;&lt;P&gt;
y&lt;/P&gt;&lt;P&gt;    
y&lt;/P&gt;&lt;P&gt;    
y&lt;/P&gt;&lt;P&gt;    
n&lt;/P&gt;&lt;P&gt;    
------------------
Output: -- This is what i am expecting&lt;/P&gt;&lt;P&gt;
y 80% &lt;/P&gt;&lt;P&gt;n 20%
&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jul 2017 02:31:52 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-i-would-like-to-calculate-percentage-of-column-and/m-p/190678#M65371</guid>
      <dc:creator>PentaReddy</dc:creator>
      <dc:date>2017-07-22T02:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Hive - i would like to calculate percentage of column and based on the percentage i would like to load the data into another table</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-i-would-like-to-calculate-percentage-of-column-and/m-p/190679#M65372</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/14949/reddyppr.html" nodeid="14949"&gt;@PPR Reddy&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Here goes the solution (You can do it in other ways if you choose to):&lt;/P&gt;&lt;P&gt;Column name in table a is c&lt;/P&gt;&lt;P&gt;hive&amp;gt; select * from a;&lt;/P&gt;&lt;P&gt;OK&lt;/P&gt;&lt;P&gt;y&lt;/P&gt;&lt;P&gt;y&lt;/P&gt;&lt;P&gt;y&lt;/P&gt;&lt;P&gt;n&lt;/P&gt;&lt;P&gt;hive&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Query:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;hive&amp;gt; select c,per from(  &amp;gt; select x.c c,(x.cc/y.ct)*100 per,(z.cn/y.ct)*100 pern  from  &amp;gt; (select c, count(*) cc from a group by c) x, (select count(*)ct from a) y,  &amp;gt; (select c, count(*) cn from a where c='n' group by c) z) f  &amp;gt; where pern &amp;gt; 20;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Output:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;OK&lt;/P&gt;&lt;P&gt;n 25.0&lt;/P&gt;&lt;P&gt;y 75.0&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jul 2017 03:59:21 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-i-would-like-to-calculate-percentage-of-column-and/m-p/190679#M65372</guid>
      <dc:creator>rbiswas1</dc:creator>
      <dc:date>2017-07-22T03:59:21Z</dc:date>
    </item>
  </channel>
</rss>

