Guest User

Untitled

a guest
Apr 15th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. #MLPRoducts has a list of productID's that I need to get inventory for.
  2. ParentChild has parent/child relationship (see below)
  3. product_id_parent, product_id, priority
  4. 123 431 1
  5. 123 439 2
  6. 39 201 1
  7. 48 128 1
  8. 48 129 2
  9. 48 130 3
  10. ........
  11.  
  12. The tables SA(all location) has inventory for products (see below)
  13.  
  14. Product_id LocaationID onHandQty transfer
  15. 431 41 12 1
  16. 431 23 5 0
  17. 130 41 21 39
  18. 129 78 8 2
  19. 130 38 27 0
  20. .........
  21.  
  22. The tables S1(main location) has inventory for products (see below)
  23.  
  24. Product_id onHandQty transfer
  25. 431 12 1
  26. 431 5 0
  27. 130 21 39
  28. 129 8 2
  29. 130 27 0
  30. .........
  31.  
  32.  
  33. this query below gets me all child sku's from #MLPRoducts, grabs all other child from their parents (siblings). now I need to sum up the
  34. quantities from all location by each products and show 2 columns. 1 for all locations combined from table SA, the other for the main location from table S1
  35. I attempted it but commented out as it's not working.
  36.  
  37. select
  38. PC.product_id_parent
  39. , PC.product_id
  40. , PC.Priority
  41. -- , SUM(S1.OnHand_ForReplenishment) as DC
  42. -- , SUM(SA.OnHand) as AllStores
  43. from ParentChild PC
  44. --inner join LocAll SA on SA.Product_id = PC.product_id
  45. --inner join Loc1 S1 on S1.Product_id = PC.product_id
  46.  
  47. where product_id_parent in (
  48. select product_id_parent from ParentChild where product_id in (select product_id from #MLPRoducts))
  49.  
  50. group by PC.product_id_parent, PC.Priority, PC.product_id
  51. --, S1.OnHand_ForReplenishment, SA.OnHand
Advertisement
Add Comment
Please, Sign In to add comment