图书馆借阅系统数据库设计
2.5.1 按借阅表查询历史借阅信息
(用1表示已经归还,0表示未归还)
select * from Borrow
where Bis=0;
2.5.2 查询到期未还的所有借阅者记录
(借阅者编号,姓名,图书名称,借阅日期,应还日期)
用1表示已经归还,0表示未归还
select Reader.Rno,Reader.Rname,Book.Bname,Borrow.Bstart,Borrow.Bend
from Reader,Book,Borrow
where Reader.Rno=Borrow.Rno and Book.Bno=Borrow.Bno and Bis=0;
2.5.3 按出版的统计被借阅次数,结果按降序排列,若只要显示前三,如何实现?
select Book.Bname,temp.Bno,num
from BOOK,(
select top 3 Borrow.Bno Bno,COUNT(Borrow.Rno) num
from Borrow
GROUP BY Borrow.Bno
order by Borrow.Bno desc
)temp
where Book.Bno=temp.Bno
1