问题是"列出所有付款大于平均付款额的两倍"
SELECT AVG(amount)
FROM Payments
WHERE amount > AVG(amount)*2;
答案 0 :(得分:4)
您需要子查询来计算总体平均金额:
SELECT *
FROM Payments
WHERE amount > (SELECT AVG(amount)*2 FROM Payments)
答案 1 :(得分:0)
您可以将平均值放在变量
中Declare @average int
Select @average = ...
Select * from ... Where x>= @average
答案 2 :(得分:0)
此查询可能对您有所帮助:
SELECT * FROM `Payments` WHERE amount > ((select avg(amount) from `Payments`)*2)