title: Filter Values which are greater than its AVG value in Pig/Hive
body: <p>This is my sample data:</p>
  
  <pre><code>+---------------------------+------+-----------+--------------+------------+--------+--------------+-------+------------------+
  |            Car            | MPG  | Cylinders | Displacement | Horsepower | Weight | Acceleration | Model |      Origin      |
  +---------------------------+------+-----------+--------------+------------+--------+--------------+-------+------------------+
  | Chevrolet Chevelle Malibu | 18.0 |         8 | 307.0        | 130.0      |   3504 | 12.0         |    70 | US Buick         |
  | Skylark 320               | 15.0 |         8 | 350.0        | 165.0      |   3693 | 11.5         |    70 | US Plymouth      |
  | Satellite                 | 18.0 |         8 | 318.0        | 150.0      |   3436 | 11.0         |    70 | US AMC Rebel     |
  | SST                       | 16.0 |         8 | 304.0        | 150.0      |   3433 | 12.0         |    70 | US Ford          |
  | Torino                    | 17.0 |         8 | 302.0        | 140.0      |   3449 | 10.5         |    70 | US Ford Galaxie  |
  | 500                       | 15.0 |         8 | 429.0        | 198.0      |   4341 | 10.0         |    70 | US Chevrolet     |
  | Impala                    | 14.0 |         8 | 454.0        | 220.0      |   4354 | 9.0          |    70 | US Plymouth Fury |
  | iii                       | 14.0 |         8 | 440.0        | 215.0      |   4312 | 8.5          |    70 | US               |
  +---------------------------+------+-----------+--------------+------------+--------+--------------+-------+------------------+
  </code></pre>
  
  <p>I want to find out those MPG and HorsePower on basis of each car whose values are greater than their AVG value. Like mpg > AVG(mpg) and HorsePower >AVG(HorsePower). </p>
  
  <p>What I did:</p>
  
  <pre><code>r = load '/user/CarData/cars.csv' using PigStorage(',') as (car:chararray,mpg:float,cyl:INT,disp:DOUBLE,hp:DOUBLE,weight:INT,acc:DOUBLE,model:INT,org:chararray);
  r1 = group r by car; 
  r2 = foreach r1 generate group,AVG(r.mpg) as avg_mpg,AVG(r.hp) as avg_hp,r.mpg,r.hp;
  </code></pre>
  
  <p>It will give me carname,average and bag{mpg}, now I am facing problem to filter from r2. 
  I am trying something like:</p>
  
  <p><code>FILTER r2 by r.mpg &gt; AVG(mpg) and r.hp &gt; AVG(hp)</code></p>
  
  <p>Please help me. Thanks </p>