<?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 Question PIG and HIVE Code in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Question-PIG-and-HIVE-Code/m-p/355031#M237050</link>
    <description>&lt;P&gt;Hi, i need to know how to create a code in both PIG and Hive for this data:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FrankUAM_0-1666022726138.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35951i2C310DD260CA9F26/image-size/medium?v=v2&amp;amp;px=400" role="button" title="FrankUAM_0-1666022726138.png" alt="FrankUAM_0-1666022726138.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I need to obtain the sum of the newcases for the continents, as well as which country has had the highest number of cases in each continent and their number. somethig like:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FrankUAM_2-1666023196310.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35953i5DB23D2DE56DA33B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="FrankUAM_2-1666023196310.png" alt="FrankUAM_2-1666023196310.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For pig i was trying somethig like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FrankUAM_1-1666022911623.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35952i517F869895DDA87B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="FrankUAM_1-1666022911623.png" alt="FrankUAM_1-1666022911623.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any one knows how to do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Oct 2022 16:14:43 GMT</pubDate>
    <dc:creator>FrankUAM</dc:creator>
    <dc:date>2022-10-17T16:14:43Z</dc:date>
    <item>
      <title>Question PIG and HIVE Code</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Question-PIG-and-HIVE-Code/m-p/355031#M237050</link>
      <description>&lt;P&gt;Hi, i need to know how to create a code in both PIG and Hive for this data:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FrankUAM_0-1666022726138.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35951i2C310DD260CA9F26/image-size/medium?v=v2&amp;amp;px=400" role="button" title="FrankUAM_0-1666022726138.png" alt="FrankUAM_0-1666022726138.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I need to obtain the sum of the newcases for the continents, as well as which country has had the highest number of cases in each continent and their number. somethig like:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FrankUAM_2-1666023196310.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35953i5DB23D2DE56DA33B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="FrankUAM_2-1666023196310.png" alt="FrankUAM_2-1666023196310.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For pig i was trying somethig like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FrankUAM_1-1666022911623.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35952i517F869895DDA87B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="FrankUAM_1-1666022911623.png" alt="FrankUAM_1-1666022911623.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any one knows how to do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 16:14:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Question-PIG-and-HIVE-Code/m-p/355031#M237050</guid>
      <dc:creator>FrankUAM</dc:creator>
      <dc:date>2022-10-17T16:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Question PIG and HIVE Code</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Question-PIG-and-HIVE-Code/m-p/377161#M243162</link>
      <description>&lt;P&gt;&lt;SPAN&gt;You can use the following HQL (SQL) query to find the sum of new cases for each continent and identify the country with the highest number of cases in each continent along with the corresponding case count:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WITH ContinentSum AS (
  SELECT
    continent,
    SUM(new_cases) AS total_new_cases
  FROM
    sample_table_test
  GROUP BY
    continent
),

CountryMaxCases AS (
  SELECT
    continent,
    location AS country,
    MAX(total_case) AS max_cases
  FROM
    sample_table_test
  GROUP BY
    continent, location
)

SELECT
  cs.continent,
  cs.total_new_cases,
  cm.country,
  cm.max_cases
FROM
  ContinentSum cs
JOIN
  CountryMaxCases cm
ON
  cs.continent = cm.continent
  AND cs.total_new_cases = cm.max_cases;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This query first calculates the sum of new cases for each continent in the &lt;/SPAN&gt;ContinentSum&lt;SPAN&gt; CTE (Common Table Expression). Then, it finds the country with the highest total cases in each continent using the &lt;/SPAN&gt;CountryMaxCases&lt;SPAN&gt; CTE. Finally, it joins the results from both CTEs to provide the desired output.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Sample resultset for the shared data.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;+---------------+---------------------+--------------+---------------+
| cs.continent  | cs.total_new_cases  |  cm.country  | cm.max_cases  |
+---------------+---------------------+--------------+---------------+
| Asia          | 25.0                | Afghanistan  | 25.0          |
+---------------+---------------------+--------------+---------------+&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 08:58:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Question-PIG-and-HIVE-Code/m-p/377161#M243162</guid>
      <dc:creator>ggangadharan</dc:creator>
      <dc:date>2023-10-03T08:58:56Z</dc:date>
    </item>
  </channel>
</rss>

