[SQL] Statistik
Kann man mit SQL (MySQL) zwei Summen (SUM) dividieren?
Ich möchte den gewichteten Durchschnitt vom Wert w1 mit w2 gewichtet berechnen.
Das wäre
SUM(w1*w2)/SUM(w2).
SELECT SUM(w1*w2)/SUM(w2) FROM ... geht aber nicht. Geht das überhaupt oder muß ich das im Programm machen?
Außerdem würde ich gerne den Durchschnitt aus Summen berechnen, etwas in der Art:
sums=SELECT SUM(w1) FROM table GROUP BY w2
SELECT AVG(sums);
Das funktion iert in der Form klarerweise auch nicht. hat wer eine Idee wie das gehen könnte?
Jak
____________________________________
Join the DNRC | Godwin\'s Law (thx@stona)
Documentation is like sex: If it\'s good, it\'s very, very good. If it\'s bad, it\'s better than nothing.
\"In theory, theory and practice are the same. In practice, they are not\" (Lawrence Berra)
|