4 Replies Latest reply: Feb 19, 2015 3:00 AM by Arvid Rosén RSS

    Split fee among products in order

    Arvid Rosén

      Hi!

      I have two tables, similar to these:

       

      Orders:

      Load * inline

      [

      OrderID, Fee

      1, 20.0

      2, 0.0

      3, 12.50

      4, 13.50

      ];

       

      Items:

      Load * inline

      [

      OrderID, Qty, ProductName,

      1, 12, "Egg"

      1, 2, "Apple"

      1, 1, "Milk"

      2, 1, "Egg"

      2, 1, "Milk"

      3, 20, "Apple"

      4, 40, "Milk"

      4, 10, "Apple"

      ];

       

      I want to present sales per product but be able to deduct fees. However, the fees are given per order, and have to be split among the products in that particular order. How can I achieve this? I have a feeling there is an easy way to do this.