試圖找出兩個平均給出錯誤之間的區別?SQL查詢平均差異顯示錯誤?
http://sqlfiddle.com/#!3/7160d/9
select * from
(
select avg(avg_stars) as avg_1
from
(
select r.mid, avg(stars) as avg_stars
from
rating r inner join movie m
on r.mid = m.mid
where year < '1980'
group by r.mid
)
)
-
(
select avg(avg_stars) as avg_2
from
(
select r.mid, avg(stars) as avg_stars
from
rating r inner join movie m
on r.mid = m.mid
where year > '1980'
group by r.mid
)
)
爲什麼'stars'聲明爲'varchar'時,它應該(顯然)只包含數值數據? –
@Damien_The_Unbeliever感謝數據類型不匹配。 –