0
我有一個MySQL聲明:MySQL單個查詢可能嗎?
SELECT name, ((AVG (q1) + AVG(q2) + AVG(q3)/3) AS Average
FROM tresults GROUP BY name ORDER BY name;
我也有另一個MySQL statment:
SELECT name, ((AVG (q1) + AVG(q2) + AVG(q3)/3) AS Average
FROM tresults WHERE q35 = 1 GROUP BY name ORDER BY name;
我使用子查詢的嘗試,但因爲它返回多行下面的代碼無法正常工作:
SELECT name, ((AVG (q1) + AVG(q2) + AVG(q3)/3) AS Average,
(SELECT ((AVG (q1) + AVG(q2) + AVG(q3)/3)
FROM tresults WHERE q35 = 1 GROUP BY name ORDER BY name) AS Average2
FROM tresults GROUP BY name ORDER BY name;
是否可能以及該語句的結構是什麼樣子?
在此先感謝您的任何反饋意見和建議。
柳可以使用UNION ALL的2個查詢之間。 – Mihai