SELECT
分组字段,
AVG(目标字段)
FROM(
SELECT *,
ROW_NUMBER() OVER(PARTITION BY 分组字段 ORDER BY UNIQUE字段) AS R1,
ROW_NUMBER() OVER(PARTITION BY 分组字段 ORDER BY UNIQUE字段) AS R2
FROM TABLE)
WHERE ABS(R1-R2)=1 OR R1=R2
GROUP BY 分组字段
04-09
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-23
1752
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)