Home » SQL & PL/SQL » SQL & PL/SQL » How to sum a field in 2 (or more) different records
How to sum a field in 2 (or more) different records [message #3062] Mon, 02 September 2002 23:18 Go to next message
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.
Re: How to sum a field in 2 (or more) different records [message #3066 is a reply to message #3062] Tue, 03 September 2002 00:53 Go to previous message
Bhola Panta
Messages: 5
Registered: September 2002
Junior Member
Keith:
Thank you. It works!
Previous Topic: Package when ?
Next Topic: ORA-01002: Fetch Out of Sequence
Goto Forum:
  


Current Time: Tue Apr 23 01:21:40 CDT 2024