当前位置:首页 » 编程语言 » sql查询所有人都借阅过的图书信息
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

sql查询所有人都借阅过的图书信息

发布时间: 2023-03-28 03:11:36

sql 图书管理系统的查询语句

1. 求总藏书量、藏书总金额,总库存册数、最高价、最低价。
select count(图书编号) as 总藏书量,
sum(定价) as 藏书总金额,
sum(实际数量) as 总库存册数,
max(定价) as 最高价,
min(定价) as 最低价
from 图书卡片
go
2. 列出藏书在10本以上的书(书名、作者、出版社、年份)。
select 图书名称,作者姓名,出版社,出版日期
from 图书卡片
group by 图书编号 having(coung(1)>10)
order by 图书名称
go
3. 哪些出版社的藏书种类数超过100种。
select 出版社 as '藏书种类数超过100种的出版社'
from 图书卡片
group by 出版社 having(count(类别)>100)
order by 出版社
go
4. 目前实际已借出多少册书?
select sum(借出数量) as '借出数量'
from 图书卡片
go
5. 年份最久远的书。
select top 1 with ties 图书名称 from 图书卡片
order by 出版日期
go
6. “数据库系统原理教程,王珊编,清华大学出版社,1998年出版”还有几本?
select count(1) from 图书卡片
where concaints(摘要,'"数据库系统原理教程,王珊编,清华大学出版社,1998年出版"')
go
7. 哪一年的图书最多?
select top 1 with ties convert(substring(出版日期,1,4)) as 年份,count(1) as '图书数量'
from 图书卡片
group by 出版日期
order by 图书数量 desc
go
8. 哪本借书证未归还的图书最多?
select top 1 with ties A.读者编号,count(1) as '借书数量'
from 图书卡片 A,借阅 B
where A.图书编号=B.图书编号
group by A.读者编号
order by 借书数量 desc
go
9、平均每本借书证的借书册数。
select avg(借阅数量) as '平均每本借书证的借书册数'
from 借阅
go

10.哪个系的同学平均借书册数最多?
select top 1 with ties A.工作单位,avg(借阅数量) as '平均借阅数量'
from 读者 A,借阅 B
where A.读者编号=B.读者编号
group by A.工作单位
order by 平均借阅数量' desc
go

11. 最近两年都未被借过的书。
select 图书名称
from 图书卡片
where 图书编号 in(select 图书编号 from 借阅 where datediff(year,借阅日期,getdate())>2)
go
12. 列出那些借了图书逾期未归还的借书证号和图书名。
select A.读者编号 as '借书证号',B.图书名称
from 读者 as A inner join 图书卡片 as B on A.图书编号=B.图书编号
where A.应归还日期<getdate() and A.实际归还日期 is null
go
13.今年未借过书的借书证。
select 读者编号
from 读者
where 读者编号 not in(select 读者编号
from 读者
where datediff(year,借阅日期,getdate())=0)
go

14. 今年那种书出借最多?
select top 1 with ties A.类别,count(1) as '借出数量'
from 图书卡片 A,借阅 B
where datediff(year,B.借阅日期,getdate())=0
group by A.类别
order by 借出数量' desc
go

⑵ 用SQL查询借过书的读者的借阅信息,包括读者姓名、借书书名、借书日期、还书日期及书的价格

select 读者姓名,借书书名,借书日期,还书日期,价格from student
left outer join book on book.学号=student.学号 a left outer join borrow
on a.书号=borrow.书号
这个问题你必须提供数据表结构,否则没法回答啊,上面是我猜的

⑶ SQL查询至少借阅三本图书的读者编号,姓名,图书编号,图书名称,按读者编号排序输出

一张表:借阅表(包含所有信息)
select 读者编号,姓名,图书编号,图书 from 借阅表 where 读者编号 in (select 读者编号 from 借阅表 group by 读者编号 having count(读者编号)>=3)
二张表:借阅表 ,个人信息基本表
select t1.读者编号,t1.姓名,t2.读书编号,t2.读书 from 个人信息基本表 t1,借阅表 t2 where t2.读者编号 in (select 读者编号 from 借阅表 group by 读者编号 having count(读者编号)>=3) and t1.读者编号=t2.读者编号

⑷ 求助解答下面SQL查询语句

第1个:select 读者姓名 from readers where 编号 in (
select 读者编号 from borrowinf
where 借期=to_date('20110506','yyyymmdd')
)
第2个:
select * from books where 书名 in
( select 书名 from books
group by 书名having count(*)>1
)
order by 书名,书号
第3个:
select 姓名 from readers where 编号 not in (
select 读者编号 from borrowinf)
第4个:select 编号,姓名 from readers
where 编号 in (
select 读者编号 from borrowinf,books
where borrowinf.图书编号=books.编号 and 出版社='教育皮绝出版社'
)

第5个:select 书价,书燃碰姿名 from books where 书价 in
(select min(书价)from books)
第6个:select * from books order by 书价
第7个:create view jyqx as
select a.编号,c.借期,b.借阅期限,c.还期,(c.借期+b.借阅期限) "应还日期" from books a,readers b,
borrowinf c
where a.编号=c.编号and c.读者编号=b.编号
第8个:select * from borrowinf b where b.还期<sysdate
第9个:select * from borrowinf where 读者编号='xxxxx'
第10个:create or replace procere jys_test(c_name varchar2) is
ast varchar2(500);
begin
ast := 'drop table test';
execute immediate ast;
ast := '吵稿create table test as
select * from books where rownum < 0';
execute immediate ast;
ast:='
insert into test
select *
from books a
where a.图书编号 in
(select c.图书编号 from borrowinf c
where c.读者编号 in
(select b.读者编号 from readers b where b.读者姓名 = '''||c_name||'''))';
execute immediate ast;
end;
先写这么多,明天继续!

⑸ 设计图书管理系统sql查询语句

1
SELECT *
FROM C
WHERE C# IN(SELECT C# FROM SC GROUP BY C# HAVING COUNT(*) BETWEEN 2 AND 4)
2
SELECT S#
FROM SC JOIN C ON SC.C#=C.C#
WHERE CN='计算机基础'
GROUP BY S#
HAVING COUNT(*)>=2

⑹ SQL语句 查询统计借阅.dbf,显示每种图书的书号,借阅次数. 求大神赐我答案

现有三张表,分别是:图书.dbf,读者.dbf,借阅.dbf,
查询统计借阅.dbf,显示每种图书的书号,借阅次数。

select 图书书号,借阅次数 from 借阅.dbf

查询图书.dbf,显示所有书名包含“基础”二字的图书信息。

select * from 图书.dbf where 书名 like '%基础%'

按办证日期先后顺序显示读者.dbf中的读者信息。

select * from 读者.dbf order by 办证日期 asc(或者desc)

查询显示被借阅次数最多的前三名图书的书号,书名,借阅次数。

select 书号,书名,借阅次数 from 借阅.dbf where 借阅次数 in (select top 3 借阅次数 from 借阅.dbf order by 借阅次数 desc)

查询图书.dbf显示图书的平均价格。

select avg(sum(图书价格)) from 图书.dbf

查询统计读者.dbf,显示男、女读者各有多少人。

select 性别,count(性别) as 人数 from 读者.dbf group by 性别

查询图书.dbf,显示所有书名包含“程序”二字的图书信息。

select * from 图书.dbf where 书名 like '%程序%'

查询统计图书.dbf,显示出版社名及各个出版社的图书总数。

select 出版社,count(出版社) as 图书总数 from 读者.dbf group by 性别

查询显示至少被借阅了2次的图书的书号及书名

select 书号,书名 from 图书.dbf where 借阅次数>2

很辛苦啊,采纳下吧^_^

⑺ sql 查询 每个人借了几本书

select a.name,count(*) from 用户 a,借仿扮橘缺戚阅 c where a.id=c.userid
group by a.name

图备团书表没用,用第一个和第三个就行

⑻ 麻烦高手解答下哦。SQL查询的问题。谢啦。

1、select 图书编号,图书名称,作者姓名,出版社名,出版号,出版时间,单价 from 图书 where 单价=(select max(单价) from 图书)
2、没看懂历轮
3、select 图书分类.分类号,图书分类.分类名称,a.借阅次数 from (select 图书.分类号,count(*) as 借阅次数 from 图书,借阅 where 图书.图书编号=借阅.图书编号 group by 图书.分类号) as a,图书分类 where 图书分类.分类号=a.分类号弊誉
4、select 读者.读者编号,读者.姓名,读者.工作单位
from 读者,(select 读者编号肢卜信 from 借阅 where 是否归还='0' group by 读者编号) aas a
where a.读者编号=读者.读者编号

⑼ 用SQL语句查询借阅图书的总数超过5本的读者号及其借阅图书数量

select 读者号纳仿,借阅图书数量 from 表 group by 读洞档纤者号,借阅图书数量 having count(蠢桥读者号)>5

⑽ sql语句查询(图书借阅)

1,查询所有借过书的学生编号,姓名,专业,?SELECT DISTINCT borrow.stuid, student.major
FROM borrow LEFT OUTER JOIN
student ON borrow.stuid = student.stuID2,借书但是未归还的学生姓名及该生未归还书的图书数量?SELECT student.stuName, COUNT(1) AS Expr1
FROM borrow LEFT OUTER JOIN
student ON student.stuID = borrow.stuid
WHERE (borrow.b_time IS NULL)
GROUP BY student.stuName3,比如书名是《天龙八部》,请分别查询借过它的人的姓名,借书日期,看了多少天,要考虑若某人借了但是没还,则在看了多久一栏填上(尚未归还)SELECT student.stuName, borrow.t_time, CASE WHEN borrow.b_time IS NULL THEN '尚未归还' ELSE cast(datediff(day,t_time,b_time) as varchar) END AS Expr1
FROM borrow LEFT OUTER JOIN
student ON student.stuID = borrow.stuid LEFT OUTER JOIN
book ON borrow.bid = book.Bid
WHERE (book.title = '天龙八部')