非常感谢!系统限死,只能给100分。麻烦大神了。 ------解决方案-------------------- WITH T AS
(SELECT 1 ID, 2 SCORE
FROM DUAL
UNION ALL
SELECT 1, 4
FROM DUAL
UNION ALL
SELECT 10, 5
FROM DUAL
UNION ALL
SELECT 11, 2 FROM DUAL)
SELECT ID, S_SUM / CNT
FROM (SELECT ID, SUM(SCORE) S_SUM, COUNT(ID) CNT FROM T GROUP BY ID)
ORDER BY ID; ------解决方案-------------------- 难道用avg不行么
select c1,avg(c2) c2
from table
group by c1
order by c1
------解决方案-------------------- 哈哈,lz说不要效率的也行,我给他整个没效率的 ------解决方案-------------------- SELECT 字段1, AVG (字段2) vagval
FROM table1
GROUP BY 字段1
ORDER BY 字段1; ------解决方案-------------------- select t.c1,avg(t.c2) from t group by t.c1 order by t.c1; ------解决方案-------------------- 求平均数不是聚组函数avg的基本功能么
select a,avg(b) b from table group by b order by b ------解决方案--------------------