SELECT * FROM dbo.YeJi SELECT t.jidu,SUM(amount) FROM ( SELECT (y.month+2)/3 AS jidu,y.* FROM dbo.YeJi y )t GROUP BY t.jidu SELECT t.jidu,AVG(amount) FROM ( SELECT (y.month+2)/3 AS jidu,y.* FROM dbo.YeJi y )t GROUP BY t.jidu
id month amount
1 1 1.00
2 2 2.00
3 3 3.00
4 4 4.00
5 5 5.00
6 6 6.00
7 7 7.00
8 8 8.00
9 9 9.00
10 10 10.00
11 11 11.00
12 12 12.00
=================
jidu 总量
1 6.00
2 15.00
3 24.00
4 33.00
==============
jidu 平均值
1 2.000000
2 5.000000
3 8.000000
4 11.000000
时间: 2024-10-09 04:32:27