Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to correctly GROUP this Data Set
    primarykey
    data
    text
    <p>I am looking at shipment data for the past 12 months and want the total finished goods units shipped and their raw material counter parts.</p> <p>I have joined the shipment detail table with the bill of materials header (which has the corresponding finished good item) and then joined the BOM HEader to the BOM Detail to get all the Raw Material components and quantities per Finished Good Unit.</p> <pre><code>ShipYear ShipMonth CLASS SHIPMENT_ID INTERNAL_SHIPMENT_LINE_NUM FG_ITEM FG_QTY RM_ITEM RM_QTY_PER_FG_UNIT TOTAL_RM_QTY 2013 6 SHADE CHIPS 9701316 25851201 PM9000015050 2 PM1000010932 2 4 2013 6 SHADE CHIPS 9701316 25851201 PM9000015050 2 PM1000010933 3 6 2013 6 SHADE CHIPS 9701316 25851201 PM9000015050 2 PM1000010934 1 2 2013 6 SHADE CHIPS 9701316 25851201 PM9000015050 2 PM1000010935 4 8 2013 6 SHADE CHIPS 9701316 25851201 PM9000015050 2 PM1000010936 1 2 2013 6 SHADE CHIPS 9701316 25851201 PM9000015050 2 PM1000010937 1 2 2013 6 SHADE CHIPS 9701316 25851201 PM9000015050 2 PM1000010938 1 2 2013 6 SHADE CHIPS 9701316 25851201 PM9000015050 2 PM1000010939 1 2 2013 6 SHADE CHIPS 9701316 25851202 PM9000015074 5 PM1000010932 4 20 2013 6 SHADE CHIPS 9701316 25851202 PM9000015074 5 PM1000010933 1 5 2013 6 SHADE CHIPS 9701316 25851202 PM9000015074 5 PM1000010934 3 15 2013 6 SHADE CHIPS 9701316 25851202 PM9000015074 5 PM1000010935 8 40 2013 6 SHADE CHIPS 9701638 25853677 PM9000015394 1 PM1000010932 1 1 2013 6 SHADE CHIPS 9701638 25853677 PM9000015394 1 PM1000010933 1 1 2013 6 SHADE CHIPS 9701638 25853677 PM9000015394 1 PM1000010934 1 1 2013 6 SHADE CHIPS 9701638 25853677 PM9000015394 1 PM1000010935 4 4 2013 6 SHADE CHIPS 9701638 25853677 PM9000015394 1 PM1000010936 1 1 2013 6 SHADE CHIPS 9701638 25853677 PM9000015394 1 PM1000010937 2 2 2013 6 SHADE CHIPS 9701638 25853677 PM9000015394 1 PM1000010938 3 3 2013 6 SHADE CHIPS 9701638 25853677 PM9000015394 1 PM1000010939 1 1 2013 6 SHADE CHIPS 9701639 25853678 PM9000015404 1 PM1000010932 7 7 2013 6 SHADE CHIPS 9701639 25853678 PM9000015404 1 PM1000010933 1 1 2013 6 SHADE CHIPS 9701639 25853678 PM9000015404 1 PM1000010934 1 1 2013 6 SHADE CHIPS 9701639 25853678 PM9000015404 1 PM1000010935 1 1 2013 6 SHADE CHIPS 9701639 25853678 PM9000015404 1 PM1000010936 1 1 2013 6 SHADE CHIPS 9701639 25853678 PM9000015404 1 PM1000010937 1 1 2013 6 SHADE CHIPS 9701639 25853678 PM9000015404 1 PM1000010938 1 1 2013 6 SHADE CHIPS 9701639 25853678 PM9000015404 1 PM1000010939 1 1 TOTALS 9 58 136 </code></pre> <p>Here is a pic that is formatted a little better: <img src="https://i.stack.imgur.com/6QaIS.jpg" alt="enter image description here"></p> <p>In the end, I want to see the following:</p> <pre><code>Year Month Class FG Units RM Units 2012 6 SHADE CHIPS 3449 50351 2012 7 SHADE CHIPS 288 3714 2012 8 SHADE CHIPS 282 4498 2012 9 SHADE CHIPS 105 1528 2012 12 SHADE CHIPS 539 4002 2013 1 SHADE CHIPS 1972 15284 2013 2 SHADE CHIPS 121 781 2013 3 SHADE CHIPS 60 808 2013 4 SHADE CHIPS 74 1335 2013 5 SHADE CHIPS 5 40 2013 6 FILLER SHADE 1 18 2013 6 SHADE CHIPS 4788 36790 2013 7 FILLER SHADE 1 18 2013 7 SHADE CHIPS 207 1600 </code></pre> <p>I tried doing an initial group by year month, class, shipID, Internal Ship Line, Item, and take max of FG_Qty and Sum of RM_Qty. Then took that result and grouped it again, this time only grouping by year month, class and then summing FG_Qty and RM_Qty. </p> <p>Note: Just doing a straight group by in one pass isn't working because the sum of FG_QTY is overstated since in the raw data the FG_QTY is replicated in multiple rows because of the join to the BOM Details table. So I need to only count the FG_Qty once per Internal SHipment Line Nbr.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload