select start, end, avg(value) from (
select t2.start, t2.end, t1.value from t1 left join t2 on t1.key between t2.start and t2.end
) as x group by start,end
效果见下图:
计算一条记录的平均值实际上就是横向求平均值,可以参考下例:select id, (col1+col2+ col3)/3 as avgVal from T1 where id=123
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)