title: Mongo Look up in java with sum group and conditions
body: <p>I Have 2 mongo DB Collections and i would like join them and that works fine for me using lookup 
  but before i do a look up i want to group and sum in one collection with condition</p>
  
  <p>Ex: Collection A
  ID,
  AMT,
  TYPE ( 1, 2) </p>
  
  <p>Collection B
  ID ,
  TAMT1,
  TAMT2,</p>
  
  <p>Now on Collection A 
  if(TYPE==1) Then Sum(amt) as TAMT1 if(TYPE==2) Sum(AMT) as TAMT2 group by ID  and then compare with Collection B</p>
  
  <p>Can any one  hint/guide me  how to do it java </p>