title: scalars can only be used with projection in PIG
body: <p>scalars can only be used with projection i am getting this error while using foreach.How can i resolved this error ? how can i use LIMIT within foreach ? please suggest some
  thanks in advance..</p>
  
  <p><strong>Edit (Tichdroma):</strong> Copied code from comment</p>
  
  <pre><code>A = LOAD 'part-r-00000';
  G = Group A by ($0,$2 );
  Y = foreach G generate FLATTEN(group), FLATTEN($1);
  sorted = order Y by $0 ASC, $1 DESC;
  X = foreach Y {
    lim = LIMIT sorted 3;
    generate lim;
  };
  Dump x;
  </code></pre>