select sum(distinct column ) from ....
505152May 12 2006 — edited May 12 2006Hello 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