Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

select sum(distinct column ) from ....

505152May 12 2006 — edited May 12 2006
Hello All,

I have a table the contains ID and size.

An ID identifies a unique object, but it can be repeated. The following is valid:

ID Size
-----------------
1 3
4 5
5 3
1 3


What I am trynig to do is get the sum of all sizes in the table. I tried this query:

select sum(distinct size) from table;

But it does give the right result since different objects could have the same size. I tried

select sum(size) group by ID;

But it prints to me huge number of IDs and sums the sizes of an ID together. What I want thuogh is to look at the unique rows (without duplicates) and then sum their sizes together and get the result.

Any help would be greatly appreciated.
Thank you

P.S.: Sorry, I am an absolute Oracle/SQl newbie.

Thanks for your help in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 9 2006
Added on May 12 2006
4 comments
3,741 views