10-121 A3-1查询订单表中的平均运费
查询订单表(orders)
的平均运费
,并将其重命名为avgFreight
提示:请使用SELECT语句作答。
select avg(Freight) as avgFreight
from orders
10-122 A3-2查询国家为Mexico、Germany的客户数量
查询出顾客表(customers)
中查询国家(Country)
为Mexico
、Germany
的客户数量,并重命名为custCount
提示:请使用SELECT语句作答。
select count(CustomerID) as custCount
from customers
where Country in('Mexico','Germany')
10-123 A3-3查找产品表中最低的单价
在产品表(products)
中查询最低的单价(UnitPrice)
,并重命名为minUnitPrice
提示:请使用SELECT语句作答。
select min(UnitPrice) as minUnitPrice
from products
10-124 A3-4查询产品表中最大库存量
在产品表(products)
中查询最多的库存数量(UnitsInStock)
,并重命名为maxUnitsInStock
提示:请使用SELECT语句作答。
select max(UnitsInStock) as maxUnitsInStock
from products
10-125 A4-1查找订单表中每位顾客的平均运费
查询订单表(orders)
中每位顾客的平均运费
,结果显示为顾客编号(CustomerID)
和平均运费(avgFreight)
提示:请使用SELECT语句作答。
select CustomerID,avg(Freight) as avgFreight
from orders
group by CustomerID
10-126 A4-2统计顾客表中每个国家的顾客数量
查询出顾客表(customers)
中查询每个国家的客户数量,显示为国家(Country)
和客户数量(custCount)
提示:请使用SELECT语句作答。
select Country,count(CustomerID) as custCount
from customers
group by Country
10-127 A4-3在订单表中查找特定国家且平均运费不小于10的信息
查询订单表(orders)
中查找所在国家(ShipCountry)
为Belgium
,Switzerland
,且平均运费不小于10的的顾客及运费信息,结果显示为顾客编号(CustomerID)
和平均运费(avgFreight)
提示:请使用SELECT语句作答。
select CustomerID,avg(Freight) as avgFreight
from orders
where ShipCountry in('Belgium','Switzerland')
group by CustomerID
HAVING AVG(Freight)>=10
10-128 A4-4查找产品表中平均订购数大于特定值的产品信息
在产品表(products)
中查找平均订购数量大于15的产品信息,显示为:产品编号(ProductID)
,和总订货数量(重命名为sumUnitsOnOrder
)
提示:请使用SELECT语句作答。
select ProductID,sum(UnitsOnOrder) as sumUnitsOnOrder
from products
group by ProductID
having avg(UnitsOnOrder)>15
10-129 4-1 查询速度至少为160MHz的PC的制造商
本题目要求编写SQL语句,
查询速度至少为160
MHz的PC
的制造商。
提示:请使用SELECT语句作答。
select distinct maker
from product join pc on product.model=pc.model
where speed >= 160
10-130 4-2 查询价格最高的打印机型号
本题目要求编写SQL语句,
查询价格最高的打印机
型号。
提示:请使用SELECT语句作答。
select model
from printer
order by price desc
limit 1