How to sum a field in 2 (or more) different records [message #3062] |
Mon, 02 September 2002 23:18 |
Bhola Panta
Messages: 5 Registered: September 2002
|
Junior Member |
|
|
I have a Table T. Name, ID and Pref are primary keys.
-----------------
Name ID Pref Item
101 501 B01 43000
101 502 B01 2000
102 507 B01 525
102 508 B02 820
----------------------------
I want to write a SELECT quety to get the following result:
Name Pref Item
101 B01 45000
102 B01 525
102 B02 820
That is, if Name and Pref fields are same, I want to add the item field.
------------------------
SELECT Name, Pref, SUM(Item)
FROM Table T
WHERE XXXXXXXXX
---------------------
Please help. Thank you.
Bhola.
|
|
|
|