江西财经大学数据库SQL实验答案

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

SQL三

1.select 读者编号,姓名,性别from 读者where 工作单位="江西财经大学国际学院"

1.select 读者编号,姓名,性别from 读者where 工作单位like "*国际学院*"

2.select 分类号,max(单价) as 最高价格,avg(单价) as 平均价格from 图书group by 分类号order by max(单价) desc

3.select * from 图书where 图书名称like "*Java*"

4.select 图书编号,出版时间,入库时间,图书名称from 图书where year(入库时间)>=1992 and year(入库时间)<=2000 order by 入库时间

5.select 分类号,sum(库存数量) as 库存总量from 图书group by 分类号

6.select 图书名称,作者姓名from 图书where 作者姓名like "张*" or 作者姓名like "王*"

SQL四

1.

select 读者编号,姓名,工作单位from 读者where 读者编号in (select 读者编号from 借阅where not 是否归还)

select distinct 读者.读者编号,姓名,工作单位from 读者,借阅

where 读者.读者编号=借阅.读者编号

and not 是否归还

2.

select c.图书编号,c.图书名称,借阅日期,归还日期

from 读者a,借阅b,图书c

where a.读者编号=b.读者编号

and b.图书编号=c.图书编号

and 姓名="马永强"

3.

select 图书名称,作者姓名,出版社名

from 图书a,图书分类b

where a.分类号=b.分类号

and 分类名称="文学类"

4.

select a.读者编号,姓名,图书名称,借阅日期,归还日期

from 读者a,借阅b,图书c

where a.读者编号=b.读者编号and b.图书编号=c.图书编号

and 工作单位="江西财经大学国际学院"

and not 是否归还

5.

select a.读者编号,姓名,图书名称,借阅日期,归还日期

from 读者a,借阅b,图书c

where a.读者编号=b.读者编号

and b.图书编号=c.图书编号

and 出版社名="清华大学出版社"

6.

select 分类名称,sum(库存数量) from 图书a,图书分类b where a.分类号=b.分类号group by b.分类号,分类名称

select a.读者编号,姓名,c.图书编号,图书名称,借阅日期

from 读者a,借阅b,图书c

where a.读者编号=b.读者编号

and b.图书编号=c.图书编号

and year(借阅日期) between 2005 and 2006

8.

select a.读者编号,姓名,sum(单价)

from 读者a,借阅b,图书c

where a.读者编号=b.读者编号and b.图书编号=c.图书编号

group by a.读者编号,姓名

having sum(单价)>=150

SQL五

1.

select 读者编号,姓名,工作单位

from 读者

where 读者编号in (select 读者编号from 借阅where not 是否归还)

2.

select 姓名from 读者where 读者编号not in (select 读者编号from 借阅)

3.

select 读者.读者编号,姓名,借阅.图书编号,图书名称FROM 图书,读者,借阅

WHERE 读者.读者编号=借阅.读者编号AND 图书.图书编号=借阅.图书编号

and 读者.读者编号in (select 读者编号from 借阅GROUP BY 读者编号HA VING COUNT(*)>=3) order by 读者.读者编号

4.

select 读者编号,姓名,工作单位

from 读者

where 读者编号in (select 读者编号from 借阅where not 是否归还)

4.

select distinct 读者.读者编号,姓名,工作单位

from 读者,借阅

where 读者.读者编号=借阅.读者编号

and not 是否归还

5.

select 读者编号,姓名

from 读者

where 读者编号not in (select 读者编号from 借阅a,图书b,图书分类c where a.图书编号=b.图书编号and b.分类号=c.分类号and 分类名称="管理类")

SQL六

1.

update 图书set 单价=单价+5 where 分类号=(select 分类号from 图书分类where 分类名称="计算机应用类")

update 借阅set 是否归还=true where 读者编号in (select 读者编号from 读者where 身份证号like "??????1987*")

3.

insert into 借阅values("06-00008","003-000024",#2007-3-25#,#2007-5-25#,false)

4.

delete from 借阅where year(借阅日期)=2006 and month(借阅日期)=8

5.

delete from 借阅where 读者编号=(select 读者编号from 读者where 姓名="欧阳思思")

6.

select 图书编号,图书名称,入库时间

from 图书

where 入库时间between [请输入入库时间下限] and [请输入入库时间上限]

相关文档
最新文档