pape pape - 6 months ago 25
SQL Question

SQL - sum of column

I'm trying to create a SQL query that will sum column that have the same No_. How can I sum the Quantity?

select Item.No_, Entry.[Posting Date], Entry.Quantity, MinMax.Maximum
FROM Item
join Entry
on Item.No_ = Entry.[Item No_]
join MinMax
on Item.No_ = MinMax.Item No_


The output:

enter image description here

but I want the output is sum of Quantity 10+5=15

enter image description here

Answer

Try the following although without test information the group by may not be correct/ work as expected.

select  Item.No_, Entry.[Posting Date], Sum(Entry.Quantity) as TotalQuantity, MinMax.Maximum
FROM Item
join Entry
on Item.No_ = Entry.[Item No_]
join MinMax
on Item.No_ = MinMax.Item No_
Group By Item.No_, Entry.[Posting Date], MinMax.Maximum