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 -> SQL: Inner Join ??

SQL: Inner Join ??

From: Noodles <noodles_at_aol.com>
Date: 17 Nov 1998 22:47:00 GMT
Message-ID: <19981117174700.27053.00000628@ng05.aol.com>


I'm trying to do an aggregate, SUM, on a column while also selecting each value included in the SUM grouping. For Example:

A		B		C
--		--		--
10		20		1
10		21		2
10		22		1
11		23		1
11		24		1


I would like an output each B value along with C's "B" value divided by SUM(C) grouped by A. Basically it's a distribution of each C value over the sum of the C values within each unique A

ie

		20	0.25    			 where 0.25 = 1/(1+2+1)
		21	0.50				 where 0.50 = 2/(1+2+1)
		22	0.25				 where 0.25 = 1/(1+2+1)
		23	0.50				 where 0.50 = 1/(1+1)
		24	0.50				 where 0.50 = 1/(1+1)


I can get parts of this to work but I need 2 levels of access: One; for the SUM of C grouped by A, Two; A row-level select within each group ID. I think an inner or self-join is the correct path but I can't get the syntax right.

Is SQL the right way because I think I might a looping construct from PL/SQL ? I'm leaning towards SQL because ultimately I plan to use this SQL in a view.

Can anybody please point me in the right direction ?

TIA,
Cliff
(noodles_at_aol.com)
(clifford_buetikofer_at_merck.com)
Received on Tue Nov 17 1998 - 16:47:00 CST

Original text of this message

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