Ich verwend MySQL 4.0.21.
Werd' wohl updaten müssen.
Deine Vorschläge enden alle in Fehlermeldungen:
SELECT SUM(w1*w2) AS s1, SUM(w2) AS s2, s1 / s2 FROM table
#1054 - Unknown column 's1' in 'field list'
SELECT (SELECT SUM(w1*w2) FROM table) / (SELECT SUM(w2) FROM table ) AS test
FROM table
#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT SUM( w1*w2 ) FROM table ) / ( SELECT SU
#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT SUM(w1) FROM table GROUP BY w2) FROM ta
Man kann die Probleme aber mit 2 SQL-Statements lösen:
SELECT @s1 := SUM(w1*w2) , @s2 := SUM(w2) FROM table;
SELECT @s1 / @s2 FROM table LIMIT 1
SELECT @s1:=SUM( hours )
FROM courses
GROUP BY semester ;
SELECT AVG(@s1) FROM courses;
Find' ich aber nicht besonders schön, vor allem weil das 2. Falsche Werte liefert.
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)
|