views:

15

answers:

2

I have table "PICKITEM"

PARTID      QTY
A           1
A           3
B           11
C           8
D           5
D           3

I need a select statement that will return one line for like PARTIDs and add the qty field to together, yet also return the rest of the lines in the table as is

PARTID      QTY
A           4
B           11
C           8
D           8

Probably a newb question, but I am new to SQL syntax and queries. Any help in getting me on the right path would be appreciated!

+3  A: 
SELECT partid, SUM( qty ) As 'qty' FROM pickitem GROUP BY partid;

very basic syntax, no joins needed.

brad.v
A: 

Read the manual for GROUP BY

SELECT PARTID, SUM(QTY)
FROM PICKITEM
GROUP BY PARTID
Leventix