How to sum quantities for each kind of part number and display ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ANKIT MEHTA

    How to sum quantities for each kind of part number and display ?

    I have two tables one table has part number and qty columns the second table has part number and cell that is which cell the part number belongs to. I have to display each unique part number and the sum of quantity ordered. Also display 0 quantity for part numbers that have never been ordered. The cell name is V3 and the part number is a text column so I can't match it with the quantity column. Please help me with this query
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    This question is not clear. You need to take more care that your question makes sense. I will do what I can, but if you need more you will need to provide decent information.

    Try :

    Code:
    SELECT   t2.V3 AS [Cell]
           , t2.PartNo
           , Nz(Sum(t2.[Qty]), 0) As SumQty
    FROM     [Table2] AS t2
             LEFT JOIN
             [Table1] AS t1
      ON     t1.PartNo = t2.PartNo
    GROUP BY t2.V3
             t2.PartNo

    Comment

    Working...