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

Home -> Community -> Usenet -> c.d.o.tools -> Re: SQL BrainTeaser

Re: SQL BrainTeaser

From: Wolf Pfannenstiel <wolfp_at_cs.tu-berlin.de>
Date: 21 Jun 2001 10:05:06 GMT
Message-ID: <9gsgsi$hof$1@news.cs.tu-berlin.de>

Krisss <kmbotha_at_netinfo.ubc.ca> wrote:

Hi,

> What I'd like to do is combine rows that have the same id2 (by summing
> their value). i.e. I want to get is THIS table:
> id2 value
> ------------------------------
> a1 10
> a2 3
> a3 8
> a4 20
 

> any ideas on how I should go about this using SQL??

yes, it's rather simple.

SELECT id2, SUM(value) FROM table GROUP BY id2;

Bye,
Wolf Received on Thu Jun 21 2001 - 05:05:06 CDT

Original text of this message

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