問題:找出由製造商A.
結果集生產PC和筆記本電腦的平均價格:一個整體均價的所有項目。獲得平均錯在SQL查詢中Database Schema: Product(maker, model, type) PC(code, model, speed, ram, hd, cd, price) Laptop(code, model, speed, ram, hd, screen, price) Printer(code, model, color, type, price)
我有以下代碼:
with totalproducts
as
(select price
from pc
where model in (
select model
from product
where maker='A'
)
union
select price
from laptop
where model in (
select model
from product
where maker='A'
))
select avg(price) from totalproducts
不過,我得到的794.4444和解決方案的平均值爲754.1666
在:http://www.sql-ex.ru/learn_exercises.php練習26
任何幫助將高度讚賞
就是這樣。非常感謝 – Sam