title: Compare columns data at the same group
body: <p>I have a problem that I can't convert into sql
  Say I have 2 tables table1 and table2 such that 
  table1 of 3 columns (P, L, T) that represents before transfer state</p>
  
  <pre><code>P1 L1 t1
  P1 L1 t2
  P1 L2 t3
  P2 L5 t4
  P2 L5 t5
  P2 L6 t6
  </code></pre>
  
  <p>Table2 of 3 columns (P, L, T) that represents after transfer</p>
  
  <pre><code>P1 L3 t1
  P1 L3 t2
  P1 L4 t3 
  P2 L15 t4
  P2 L16 t5
  P2 L16 t6
  </code></pre>
  
  <p>The only difference between table1 and table2 is column L. We will have the same P and T columns.
  I would like to select the p such that the Ts that belong to the same old L are still belong to the same new L where count of Ts grouped by L > 1. </p>
  
  <pre><code>**Case** (table1)t1,t2 At L1(old L) and (Table2)t1, t2 At L3(new L). Count of T grouped by L =2  and t1, t2 belong to same L group then return P.
  
  **Case** table1: t3 at L2 and table2: t3 at L4. Count of T grouped by L =1 then ignore P.
  
  **Case** (table1)t4,t5 At L5(old L) and (Table2)t4, t5 At L15 and L16(new L). Count of T grouped by L =2  but t4, t5 belong to different L group then ignore P.
  </code></pre>
  
  <p>I need to compare both count(T) and Ts group by L and return P
  Any ideas??</p>