title: Improve efficiency of PIG Script
body: <p><B>DATASET:</B><BR>
  I have a data set (data.txt) in (ID, Category) format as given below:<BR></p>
  
  <pre><code>    01,X
      02,Y
      03,X
      04,Y
      05,X
      06,X
      07,Z
      08,Z
      09,X
      10,Z
  </code></pre>
  
  <p><BR><BR>
  <B>Objective:</B><BR>
  The objective is to find out which category has the maximum number of IDs without using UDF.
  <BR><BR>
  <B>One Approach:</B><BR>
  I have tried multiple times and concluded that this can be achived by the followins set of PIG statements</p>
  
  <pre><code> A1 = LOAD 'data.txt' USING PigStorage(',') AS (ID:int , Category:chararray);
   A2 = DISTINCT A1;
   A3 = GROUP A2 BY Category;
   A4 = FOREACH A3 GENERATE group AS Category, COUNT(A2.ID) AS Number;
   A5 = GROUP A4 ALL;
   A6 = FOREACH A5 GENERATE MAX(A4.Number);
   A7 = FILTER A4 by Number == A6.$0;
   A8 = FOREACH A7 GENERATE Category;
   DUMP A8;
  </code></pre>
  
  <p><B>Request:</B><BR>
  Although these statements give the desired result, I am not convinced with its efficiency.
  As I am new to PIG, I am not sure if there are any inbuilt functions which can perform such tasks to output the corresponding values of the minimum or maximum value of from a table.
  <BR><BR>
  My request is to know if this can be achived in any less number of steps.
  <BR><BR>
  Many Thanks</p>