harmonic mean in SQL
am 22.10.2010 01:12:21 von Ted Yu
--0016363b820681db0f049328a8ab
Content-Type: text/plain; charset=ISO-8859-1
Hi,
The mathematical way to add two "partial" harmonic means to generate new
harmonic mean is:
Let X1 , X2 be two harmonic means on different rollup rows, generated using
n1 and n2 # of facts respectively.
The combined harmonic mean would be:
(n1 + n2)/( n1/x1 + n2/x2)
If you have experience with computing harmonic mean in SQL, please share.
--0016363b820681db0f049328a8ab--
RE: harmonic mean in SQL
am 22.10.2010 13:20:01 von Jay Blanchard
[snip]
The mathematical way to add two "partial" harmonic means to generate new
harmonic mean is:
Let X1 , X2 be two harmonic means on different rollup rows, generated
using
n1 and n2 # of facts respectively.
The combined harmonic mean would be:
(n1 + n2)/( n1/x1 + n2/x2)
If you have experience with computing harmonic mean in SQL, please
share.
[/snip]
Unless I am misunderstanding your question the simplest method would be;
SELECT ((n1 + n2)/(n1/x1 + n2/x2)) AS "Harmonic Mean"=20
....without knowing the structure of the data. If X1 and X2 live on 2
different rows you could write a stored procedure to retrieve the
relevant data and produce an output.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg