We help IT Professionals succeed at work.
Get Started

SQL select statement to summarise the quantity on multiple data rows

654 Views
Last Modified: 2012-08-17
Hi experts,

Is it possible to create a SQL select query to summarise the quantity   from a small SQL table for multiple record rows? ie data from the table that contains the same data from the following fields more than once: itemcode, warehouse, bin code but summarised by the total unique quantitys.

Please see attached Excel example of current results, and results id like to be able to see if possible.

currently I have the following sql code:

SELECT T0.[U_BinCode], T0.[U_ItemCode], T0.[U_WhsCode], T0.[U_BatchNum], T0.[U_Qty_Hold], T0.[U_DocDate], T0.[U_AlocQty], SUM (T0.[U_Quantity]) as 'QtySum'
FROM [dbo].[@CTX_BINSTOCK] T0
Group by T0.[U_BinCode], T0.[U_ItemCode], T0.[U_Quantity], T0.[U_WhsCode], T0.[U_BatchNum], T0.[U_Qty_Hold], T0.[U_DocDate], T0.[U_AlocQty]
order by T0.[U_ItemCode]
Sum-Example.xlsx
Comment
Watch Question
Senior DBA
CERTIFIED EXPERT
Most Valuable Expert 2018
Distinguished Expert 2019
Commented:
This problem has been solved!
Unlock 1 Answer and 20 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE