我试图找出胶片更换成本和胶片更换成本之间的平均差异 租金率大于15.但我一直做错了。 类别在film_list表下找到,(film replacement和rental_rate)来自电影表
SELECT categories,avg(replacement_cost) as Average, -(select avg(Rental_rate) from film) as Difference FROM film,film_list WHERE Rental_rate > 17;
答案 0 :(得分:0)
为了根据类别进行平均,您需要使用group by。否则,它将执行所有类别中所有内容的平均值。
你可以尝试:
Select
categories,
AVG(replacement_cost)-AVG(Rental_rate) as Difference
From film
Group By categories
Having AVG(replacement_cost)-AVG(Rental_rate) >15