我的数据如下:
year month Amount
2012 4 7443.00
2012 5 7443.00
2012 6 7443.00
2012 7 7443.00
2012 8 7443.00
2012 9 7443.00
2012 10 7443.00
2012 11 7443.00
2012 12 7443.00
2013 1 7443.00
2013 2 7443.00
2013 3 9828.00
2013 4 8238.00
2013 5 8238.00
2013 6 8238.00
2013 7 8238.00
2013 8 8238.00
2013 9 8238.00
2013 10 8238.00
2013 11 8238.00
2013 12 8238.00
我想要最近十个月的平均金额。 提前致谢
答案 0 :(得分:0)
这是ms-server的sql:
SELECT TOP 10 year, month, amount FROM your_table_name
WHERE amount >(SELECT AVG(amount ) FROM your_table_name)
ORDER BY year, month DESC;
请试试这个。我没试过它。
SELECT TOP 10 year, month, amount FROM your_table_name
WHERE amount >(SELECT AVG(amount) AS AverageAmount FROM your_table_name)
ORDER BY year, month DESC;