Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: analytic functions vs subquery

Re: analytic functions vs subquery

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Fri, 25 Feb 2005 17:43:54 +0100
Message-ID: <421f5594$0$31961$636a15ce@news.free.fr>

"Cris Carampa" <cris119_at_operamail.com> a écrit dans le message de news:421f0d73$0$32342$5fc30a8_at_news.tiscali.it...
| Hello, let's suppose I have this denormalized table:
|
| ID NUM
| ---------- ----------
| 1 7
| 1 7
| 1 7
| 2 9
| 3 9
| 4 3
| 4 3
|
| I wish to sum the NUM values but I wish to take just one NUM for each
| distinct ID value, e.g.:
|
| 7+9+9+3
|
| I'm trying to find a way to do that using analytic functions instead of
| a subquery. Any hints?
|
| (of course select distinct(num) is not an option here)
|
| Thank you. Kind regards,
|
| --
| Cris Carampa (cris119_at_operamail.com)
|
| - We're gonna be like three little Fonzies here. And what's Fonzie like?
| - Cool?
|

select sum(num) from (select distinct id, num from mytable);

Regards
Michel Cadot Received on Fri Feb 25 2005 - 10:43:54 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US