How to Sum Concatated Fields in Query

zgadson

Board Regular
Joined
Jul 16, 2015
Messages
68
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Below is a small selection of my SQL, which is basically inventory data for my warehouse. I've had to combine two fields to create the location name (MAAISL is Aisle, and MASLOT is slot), so together they make AISLE_SLOT. Given this, how can I condense my PLT.QTY field into one line per location?

IE, in the yellow part of the example image, I'd like the "QTY.IN.LOC" to read as one line with a total of 10, rather than 3 separate lines. Basically, I want it to SUM the QTY.IN.LOC field based on all matching LOCATION fields.

SQL:
SELECT

CONCAT(CONCAT(LTRIM(RTRIM(MAAISL)), '_'),LTRIM(RTRIM(MASLOT))) AS LOCATION,


SUM(CASE WHEN ITUNQ3 = ' ' THEN CEIL(QTY/ITUNQ2) ELSE CEIL((QTY/ITUNQ2)/ITUNQ3) END) AS "QTY.IN.LOC"

FROM LOCXSTORER
WHERE LCSTOR = '553'
GROUP BY MAWHSE, MAAISL, MASLOT, LCSTOR, STNAME, ITDSC1, LCITEM, ITPDCD, MADEPT,ITINDP,ITINWD,ITINHI,LCLTC1
ORDER BY MAAISL ASC

Thank you!!
 

Attachments

  • Untitled.png
    Untitled.png
    10.1 KB · Views: 8

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,216,360
Messages
6,130,175
Members
449,562
Latest member
mthrasher16

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top