4

I have three tables StockSummary, Item, ItemSpecification. Here I want to join these three tables and to get Sum(StockSummary.Quantity). The main Columns are as follows:

TableA: StockSummary(ItemID, Quantity)
TableB: Item(ItemID, ItemName, SpecificationID)
TableC: ItemSpecification(SpecificationName, SpecificationID)

The desired result should give ItemName, SpecificationName and SUM(Quantity). How to use Aggregate function in Inner Joins?

1 Answer 1

7

You aggregate the desired column & group by the remainder, the fact that the columns are from the result of a join is not relevant in your case;

select
   b.ItemName,
   c.SpecificationName,
   sum(a.Quantity)
from
   tablea a
   inner join tableb b on b.ItemID = a.ItemID
   inner join tablec c on c.SpecificationID = b.SpecificationID
group by
   b.ItemName,
   c.SpecificationName
Sign up to request clarification or add additional context in comments.

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.