10-141 6-3 查询厂商"A"生产的PC的平均价格
本题目要求编写SQL语句,
查询厂商A
生产的PC
的平均价格。
select avg(price) as avg_price
from product join pc on product.model=pc.model
where maker='A'
10-142 6-4 查询厂商"D"生产的PC和便携式电脑的平均价格
本题目要求编写SQL语句,
查询厂商D
生产的PC和便携式电脑的平均价格。
SELECT round(AVG(price)) AS avg_price
FROM (SELECT price
FROM product,pc
WHERE product.model = pc.model AND maker = 'D'
UNION ALL
SELECT price
FROM product,laptop
WHERE product.model = laptop.model AND maker = 'D') temp
10-143 6-6 查询各厂商生产的便携式电脑的显示器平均尺寸
本题目要求编写SQL语句,
查询各厂商
生产的便携式电脑
的显示器平均尺寸。
select maker,avg(screen) as avg_screen
from product join laptop on product.model=laptop.model
where type='便携式电脑'
group by maker
10-144 6-7 查询生产三种不同型号的PC的厂商
本题目要求编写SQL语句,
查询生产三
种不同型号的PC
的厂商。
select distinct maker
from pc join product on product.model=pc.model
group by maker
having count(*)>2
10-145 6-8 查询各厂商生产的PC的最高价格
本题目要求编写SQL语句,
查询各厂商生产的PC
的最高价格。
select maker,max(price) as max_price
FROM pc,product
where pc.model=product.model
GROUP BY maker
10-146 6-9查询速度超过150MHZ的各种速度的PC的平均价格
本题目要求编写SQL语句,
查询速度超过150
MHZ的各种速度的PC
的平均价格。
select speed,avg(price) as avg_price
from pc
where speed>150
group by speed
10-147 A4-7在订单详细信息表中查找包含产品种类数超过特定值的订单信息
在订单详情表(orderdetails)
中查找订单中包含的不同产品的个数超过2的订单信息,显示订单号(OrderID)
和总数量(重命名为totalQuantity
)
select OrderID,sum(Quantity) as totalQuantity
from orderdetails
group by OrderID
having count(ProductID)>2
10-148 B1-3查询特定供应商及其供应的产品情况
查找来自国家(Country)
为Japan
、USA
各个供应商名称及其供应的产品,显示为:供应商编号(SupplierID)
,公司名称(CompanyName)
,产品编号(ProductID)
和产品名称(ProductName)
提示:请使用SELECT语句作答。
select products.ProductID,products.ProductName,suppliers.SupplierID,suppliers.CompanyName
from products,suppliers
where suppliers.SupplierID=products.SupplierID AND suppliers.Country in('Japan','USA')
10-149 B1-4统计各个供应商及其供应情况
统计各个国家(Country)
的供应商的供应产品情况,显示为:国家(Country)
,库存总量(重命名为sumUnitsInStock
),平均单价(重命名为avgUnitPrice
)
提示:请使用SELECT语句作答。
select suppliers.Country,sum(products.UnitsInStock) as sumUnitsInStock ,avg(products.UnitPrice) as avgUnitPrice
from products,suppliers
where suppliers.SupplierID=products.SupplierID
group by suppliers.Country
10-150 查询图书表中所有记录
本题目要求编写SQL语句,检索出图书
表中所有记录。
提示:请使用SELECT语句作答。
select * from 图书