Guest User

Untitled

a guest
Jul 23rd, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. SELECT ad.spec_id, ad.size_id, ad.height_id,
  2. (IFNULL(SUM(ad.qty),0)+IFNULL(b.move_qty,0)) as qty, SUM(ad.qty) as
  3. arrival_qty, b.move_qty as movement_qty, a.warehouse_id FROM arrival_data ad
  4. LEFT JOIN arrivals a
  5. ON ad.arrival_id = a.arrival_id
  6. LEFT JOIN (SELECT SUM(m.qty) as move_qty, m.size_id, m.height_id,
  7. m.spec_id, mb.receiver FROM movement_data m, movements mb
  8. WHERE mb.movement_id = m.movement_id GROUP BY m.size_id, m.height_id, m.spec_id,
  9. mb.receiver) b
  10. ON ad.size_id= b.size_id
  11. AND ad.height_id = b.height_id
  12. AND ad.spec_id = b.spec_id
  13. AND b.receiver = a.warehouse_id
  14.  
  15. GROUP BY ad.spec_id, ad.size_id, ad.height_id, a.warehouse_id
Add Comment
Please, Sign In to add comment