title: How to check COUNT of filtered elements in PIG
body: <p>I have the following data set in which I need to perform some steps based on the Car's company name.</p>
  
  <pre><code>            (23,Nissan,12.43)
              (23,Nissan Car,16.43)
              (23,Honda Car,13.23)
              (23,Toyota Car,17.0)
              (24,Honda,45.0)
              (24,Toyota,12.43)
              (24,Nissan Car,12.43)
  
  
            A = LOAD 'data.txt' AS (code:int, name:chararray, rating:double);
            G = GROUP A by (code, REGEX_EXTRACT(name,'(?i)(^.+?\\b)\\s*(Car)*$',1));
              DUMP G;
  </code></pre>
  
  <p>I am grouping cars based on code and their base company name like All the 'Nissan' and 'Nissan Car' records should come in 1 group and similar for others.</p>
  
  <pre><code>    /* Grouped data based on code and company's first name*/ 
              ((23,Nissan),{(23,Nissan,12.43),(23,Nissan Car,16.43)})
              ((23,Honda),{(23,Honda Car,13.23)})
              ((23,Toyota),{(23,Toyota Car,17.0)})
              ((24,Nissan),{(24,Nissan Car,12.43)})
              ((24,Honda),{(24,Honda,45.0)})
              ((24,Toyota),{(24,Toyota,12.43)})
  </code></pre>
  
  <p>Now, I want to filter out the groups based on whether they contain a tuple corresponding to group's name. If yes, take that tuple from that group and ignore others and if no such tuple exists then take all the tuples for that group.</p>
  
  <p>The Output should be:</p>
  
  <pre><code>            ((23,Nissan),{(23,Nissan,12.43)})  // Since this group contains a row with group's name i.e. Nissan
              ((23,Honda),{(23,Honda Car,13.23)})
              ((23,Toyota),{(23,Toyota Car,17.0)})
              ((24,Nissan),{(24,Nissan Car,12.43)})
              ((24,Honda),{(24,Honda,45.0)})
              ((24,Toyota),{(24,Toyota,12.43)})
  
              R = FOREACH G { OW = FILTER A BY name==group.$1; IF COUNT(OW) &gt; 0}
  </code></pre>
  
  <p>Could anybody please help how can I do this? After filtering by group's name? How can I find the count of the filtered tuples and get the required data.</p>