试验任务二
在任务一的基础上,练习查询语句的使用,包括计算列、求和、最大、最小值、各类选择条件、字符匹配、分组和排序,体会各种查询的执行过程,为简单综合应用打下基础。
查询书名以 T 开头或者出版社号为 0877,而且价格大于 16 的书的信息。
use pubs
select title,pub_id,price
from dbo.titles
where title like'T%' or pub_id like '0877' and price> 16
2 .
按照类型的升序和价格的降序(在类型相同时)显示书的信息(书名、作者、出版社、类型、价格)
select title,type,price
from dbo.publishers,dbo.titles
where dbo.titles.pub_id=dbo.publishers.pub_id
order by type,price desc;
查询销售量大于 30 的书名及销售数量
select qty,title
from dbo.sales,dbo.titles
where dbo.sales.title_id=dbo.titles.title_id and qty> 30;
查询在 1990.1.1 到 2000.12.31 间,每本书的销售总额
select title, ‘销售总额’= sum(price*qty)
from titles,sales
where ord_date between '1994.1.1' and '19