Hello! Stumped as usual on something I've unintentionally made overly complex. I have a Concatenated field LTRIM(CONCAT(MAAISL,MASLOT)) AS LOCATION that I need to use as a group. I also need to SUM the CASE WHEN line based on the group.
Goal: Eliminate duplicate values in the LOCATION column while retaining the total from the last PLT.QTY column per the yellow highlights in my worksheet. IE, Location "A1 7D" = 2 pallets, and "A1 8D" = 2 pallets.
Here's what I've got:
Goal: Eliminate duplicate values in the LOCATION column while retaining the total from the last PLT.QTY column per the yellow highlights in my worksheet. IE, Location "A1 7D" = 2 pallets, and "A1 8D" = 2 pallets.
Here's what I've got:
SELECT
LTRIM(CONCAT(MAAISL,MASLOT)) AS LOCATION,
LTRIM(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(MASLOT, 'A', ''), 'B', ''), 'C', ''), 'D', ''), 'E', ''), 'F', ''), 'G', ''), 'H', ''), 'I', ''), 'J', ''), 'K', '')) AS "SLOT.NUM",
LTRIM(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(MASLOT, '0', ''), '1', ''), '2', ''), '3', ''), '4', ''), '5', ''), '6', ''), '7', ''), '8', ''), '9', '')) AS "SLOT.LVL",
LTRIM(MAWHSE) AS WHSE,
LTRIM(MAAISL) AS AISLE,
LTRIM(MASLOT) AS SLOT,
LCSTOR,
STNAME,
LTRIM(ITDSC1) AS "ITM.DESC",
LTRIM(LCITEM) AS "ITM.CODE",
LTRIM(ITPDCD) AS FAMILY,
CASE WHEN ITUNQ3 = 0 THEN CEIL(QTY/ITUNQ2) ELSE CEIL(QTY/ITUNQ2/ITUNQ3) END AS "PLT.QTY",
LTRIM(MADEPT) AS DEPTH,
CEILING(ITINDP) AS "ITM.DPTH",
CEILING(ITINWD) AS "ITM.WDTH",
CEILING(ITINHI) AS "ITM.HGHT",
CEILING(ITPALH) AS "PLT.STACK.HGHT"
FROM LOCXSTORER