0

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

1
  • 2
    Have you tried group by and sum()? Commented Jun 7, 2016 at 9:14

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

0

You can use the sum() function:

SELECT  sum(Entry.quantity) as sum_quantity
FROM Item
    JOIN Entry ON Item.No_ = Entry.[Item No_]
    JOIN MinMaxON Item.No_ = MinMax.Item No_

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.