需要sql-ex.ru/ DML ex4的解决方案

时间:2015-05-13 05:32:02

标签: sql

我陷入了来自sql-ex

的第四个DML问题
For each group of laptops with the identical model number, add following record into PC table:
code: minimal code among laptops in the group +20;
model: laptop's model number +1000;
speed: maximal speed among laptops in the group;
ram: maximal ram size among laptops in the group *2
hd: maximal hd capacity among laptops in the group *2;
cd: default value;
price: maximal price among laptops in the group divided by 1.5.
Remark. Consider model number as numeric.

架构是

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)

提前感谢您的帮助

1 个答案:

答案 0 :(得分:0)

尝试此查询

insert into PC (code,model,speed,ram,hd,price) 
select min(code)+20,model+1000,max(speed),max(ram)*2,max(hd)*2,max(price)/1.5 
from Laptop group by model