1 、SQL语言允许使用通配符进行字符串匹配的操作,其中‘%’可以表示()D
A. 零个字符
B. 1个字符
C. 多个字符
D. 以上都可以
2 、关系数据库中空值(NULL)相当于( ) D
A. 零(0)
B. 空白
C. 零长度的字符串
D. 没有输入
3 、一个电视经销商在表Tvtype 中维护库存的Tvs信息,下述哪条语句能显示价格最昂贵的三种电视机的信息?( ) C
A. select top3 cDiscription from Tvtype order by iprice asc
B. select cDiscription from Tvtype where
max(iprice)>3
C. select top3 cDiscription from Tvtype order by iprice desc
D. select cDiscription max(iprice) from Tvtype order by iprice
1、销售数据库Sales中存在这样的三张表,按要求完成下列题目:
1.客户表Cus(CusNo, CusName, Address,Tel)
2.产品表Pro(ProNo,ProName,price,Stocks)
3.销售表ProOut(CusNo,ProNo,Quantity,SaleDate)
备注:客户编号(CusNo),姓名(CusName),地址(Address),电话(Tel),产品编号(ProNo)品名(ProName),单价(price),库存数量(Stocks),
销售日期(SaleDate),客户编号(CusNo),产品编号(ProNo),销售数量(Quantity)
(1)查询销售总数量超过100的产品号。
(5分)
(2)查询购买了产品号“P0002”的客户编号、客户名和电话,查询结果按客户名降序排列。
(6分)
(3)查询客户“C004”在2015年购买的产品号、数量。
(7分)
(4)创建视图viewPro,要求显示每种产品的销售量和销售金额(7分)
用户答案:
(1) select ProNo as 产品号 from ProOut where quantity>100
(2) select CusNo as 客户编号,CusName as 客户名,Tel as 电话 from Cus where CusNo in(select CusNo from proOut where ProNo='P0002') order by CusName desc
(3) select ProNo as 产品号,Quantity as 数量 from ProOut where CusNo='C004' and SaleDate between '2015-1-1' and '2015-12-31'
(4) use Sales
go
create view viewPro
as select pro.ProName as 产品名,proout.Quantity as 销售
量,pro.price as 销售金额 from Pro,ProOut
标准答案:
(1)
Select ProNo from ProOut group by ProNo having
sum(Quantity)>100
(2)
select P.CusNo, CusName,Tel from ProOut as p, Cus as C
where P.ProNo=’P0002’ and P . CusNo = C . CusNo
order by CusName desc
(3)
select CusNo, sum(Quantity) from ProOut
where CusNo = ’C004’ and SaleDate > '2014-12-31'
(4)
create view viewPro as
select PO.ProNo ,sum(Quantity) as '销售量',sum(Quantity *price) as '销售金额'
from Pro as P, ProOut as PO
where P.ProNo=PO.ProNo group by PO.ProNo,price。