文档库 最新最全的文档下载
当前位置:文档库 › 查询作业答案

查询作业答案

1、select 姓名,专业名,借书数 from xs
2、select 借书证号,姓名,借书数 from xs
3、select * from xs
4、select 借书证号 cardno,姓名 as name,count=借书数 from xs where 专业名='计算机'
5、select 借书证号,姓名,借书数,5-借书数 as 还可借书数 from xs
6、select distinct isbn,借书证号 from jy
7、select top 4 * from xs order by 借书数 desc
8、select * from xs where 借书数>1
9、select * from xs where 借书数>1 and 专业名='计算机'
10、select * from xs where 出生时间 between '1980-1-1' and '1982-12-31'
或者:select * from xs where 出生时间>='1980-1-1' and 出生时间<='1982-12-31'
11、select * from xs where 出生时间 not between '1982-1-1' and '1982-12-31'
或者:select * from xs where 出生时间<'1982-1-1' or 出生时间>'1982-12-31'
12、select * from xs where 专业名 in ('计算机','英语','信息工程','自动化')
或者:select * from xs where 专业名='计算机' or 专业名='英语' or 专业名='信息工程' or 专业名='自动化'
13、select * from xs where 专业名 not in ('计算机','英语','信息工程','自动化')
或者:select * from xs where 专业名!='计算机' and 专业名!='英语' and 专业名!='信息工程' and 专业名!='自动化'
15、select * from xs where 姓名 like '_小%'
16、select * from xs where 姓名 like '_[小,涛]%'
或者:select * from xs where 姓名 like '_小%' or 姓名 like '_涛%'
17、select * from xs where 专业名 is null
18、select 姓名,借书证号 from xs where 专业名='计算机' and 借书数<2
19、select 姓名,借书证号 from xs where 专业名='计算机' or 专业名='英语'
20、select * from book where 书名 like '%程序设计%'
21、select * from xs where 专业名='计算机' order by 出生时间
22、select * from xs where 专业名='计算机' order by 借书数 desc



1、select * from xs,jy where xs.借书证号=jy.借书证号
2、select xs.*,isbn,索书号,借书时间 from xs,jy where xs.借书证号=jy.借书证号
3、select 姓名,专业名 from xs,jy where isbn='7-111-06359-7' and xs.借书证号=jy.借书证号
4、select 借书证号,姓名,借书数 from xs where 借书数 between 2 and 5
或者:select 借书证号,姓名,借书数 from xs where 借书数>=2 and 借书数<=5
5、select xs.借书证号,姓名,专业名,借书时间 from xs, jy,book
where xs.借书证号=jy.借书证号 and jy.isbn=book.isbn and 书名='web站点安全'
或者:select xs.借书证号,姓名,专业名,借书时间 from xs inner join jy on xs.借书证号=jy.借书证号
inner join book on jy.isbn=book.isbn
where 书名='web站点安全'
6、select xs.借书证号,姓名,专业名,book.isbn,书名,索书号,借书时间 from xs,jy,book
where xs.借书证号=jy.借书证号 and jy.isbn=book.isbn order by xs.借书证号
或者:select xs.借书证号,姓名,专业名,book.isbn,书名,索书号,借书时间 f

rom xs join jy
on xs.借书证号=jy.借书证号 join book on jy.isbn=book.isbn order by xs.借书证号
7、select xs.*,索书号 from xs left outer join jy on xs.借书证号=jy.借书证号
8、select jy.*,书名 from jy right outer join book on jy.isbn=book.isbn
9、select * from xs cross join book
10、select xs.借书证号,姓名,专业名,book.isbn,书名,索书号,借书时间 from xs,jy,book
where xs.借书证号=jy.借书证号 and jy.isbn=book.isbn and 书名 like '%计算机%'
或者
select xs.借书证号,姓名,专业名,book.isbn,书名,索书号,借书时间 from xs inner join jy
on xs.借书证号=jy.借书证号 join book on book.isbn=jy.isbn where 书名 like '%计算机%'
11、select 借书证号,姓名,性别,出生时间,借书数 from xs where 专业名=
(select 专业名 from xs where 姓名='李宏')
12、select * from xs where 借书证号 not in
(select 借书证号 from jy where isbn=
(select isbn from book where 书名='计算机网络'))
或者:
select * from xs where 借书证号 !=all
(select 借书证号 from jy where isbn=
(select isbn from book where 书名='计算机网络'))
13、查找其他专业比所有计算机专业的学生年龄都小的学生。
select * from xs where 专业名!='计算机' and 出生时间>
(select max(出生时间) from xs where 专业名='计算机')
或者
select * from xs where 出生时间>
(select max(出生时间) from xs where 专业名='计算机')
或者
select * from xs where 出生时间>all
(select 出生时间 from xs where 专业名='计算机')
14、查找其他专业比所有计算机专业某个学生年龄小的学生。
select * from xs where 专业名!='计算机' and 出生时间>
(select min(出生时间) from xs where 专业名='计算机')
或者
select * from xs where 专业名!='计算机' and 出生时间>any
(select 出生时间 from xs where 专业名='计算机')
15、查询计算机专业学生借书的平均数,要求显示专业名和平均借书数。
select 专业名,平均借书数=avg(借书数) from xs where 专业名='计算机'
group by 专业名
16、查询图书总册数(对副本量求和)和库存图书总册数(对库存量求和。)
select sum(副本量) 图书总册数,sum(库存量) as 库存图书总册数 from book
17、查询学生总数。
select count(*) 学生总数 from xs
18、查询借阅了图书的学生的借书数。
select 借书证号,count(*) as 借书数 from jy group by 借书证号
19、查询图书的种类,即一共有多少种图书。
select count(*) 图书种类 from book
20、将xs表中的学生按专业名进行分组。
select 专业名 from xs group by 专业名
21、查询各专业学生总数。
select 专业名,count(*) as 学生总数 from xs group by 专业名
22、求被借阅图书的isbn号和借阅了该种图书的学生数。
select isbn,count(*) as 学生数 from jy group by isbn
23、查询每个专业的男生人数、女生人数


select 专业名,性别,count(*) as 人数 from xs group by 专业名,性别

相关文档
相关文档 最新文档