日期:2014-05-16 浏览次数:20934 次
select aid ,round(avg(num),2)
from (
select aid ,num,
row_number() over(partition by aid order by num) rn
from tb1
)t1
where rn < 4
group by num
------解决方案--------------------
select aid
avg(num)
from(select aid ,
num ,
row_number()over(partition by aid order by num asc) rn
from tab )
where rn<=3
group by aid