一道CompleteBook上的SQL题# JobHunting - 待字闺中
Z*4
1 楼
Product(maker,model,type)
PC(model,speed,ram,hd,price)
Laptop(model,speed,ram,hd,screen,price)
Find the average price of PC's and laptops made by manufacturer "D"
要算PC和laptop一起的AVG价格感觉是不是不用嵌套搞不定啊?
我的是
SELECT AVG(Price)
FROM (SELECT maker,Price FROM Product,PC WHERE Product.model=PC.model) AS T1
UNION
(SELECT maker,Price FROM Product,Laptop WHERE Product.model=Laptop.model) AS
T2
GROUP BY maker
HAVING maker=D
对嘛?
有没有简单的啊
PC(model,speed,ram,hd,price)
Laptop(model,speed,ram,hd,screen,price)
Find the average price of PC's and laptops made by manufacturer "D"
要算PC和laptop一起的AVG价格感觉是不是不用嵌套搞不定啊?
我的是
SELECT AVG(Price)
FROM (SELECT maker,Price FROM Product,PC WHERE Product.model=PC.model) AS T1
UNION
(SELECT maker,Price FROM Product,Laptop WHERE Product.model=Laptop.model) AS
T2
GROUP BY maker
HAVING maker=D
对嘛?
有没有简单的啊