首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

急 !多谢大家啊SQL 语句查询。多谢了。

2012-05-04 
急急急 !!!谢谢大家啊。。。SQL 语句查询。。。谢谢了。。books (图书编号,书名,作者,出版社,定价)book_id. book_n

急急急 !!!谢谢大家啊。。。SQL 语句查询。。。谢谢了。。
books (图书编号,书名,作者,出版社,定价)
  book_id. book_name, book_aut, book_pre, price
readers (读者编号,读者姓名,读者性别,办公电话,部门)
  reader_id, reader_name, reader_sex, reader_phone, dept
borrowinf (读者编号,图书编号,借期,应还日期,还期)
  reader_id, book_id, jcdate, yhdate, ghdate


SQL 查询 一下:


3.基于图书馆数据库的3个表,用T-SQL语言完成一下操作:
1)查询全体图书的图书号、书名、作者、出版社和单价
2)显示所有借阅者的读者号,并去掉重复行
3)查询全体图书的信息,其中单价打8折,并设置该列的别名为‘打折价’
4)查询所有单价在20—30元之间的图书信息
5)查询机械工业出版社、科学出版社、人民邮电出版社的图书信息
6)查询既不是机械工业出版社、也不是科学出版社出版的图书信息
7)查询姓名的第二个字符是’建’,并且只有2个字的读者的读者号及姓名
8)查询姓名不是以‘王’、‘张’或‘李’开头的所有读者的读者号及姓名
9)查询无归还日期的借阅信息
10) 查询没有按照要求及时归还图书的读者号
11)查询机械工业出版社图书的平均价格、最高价、最低价
12)查询读者的基本信息及借阅情况


请大家用 SQL 语句查询下。。谢谢啊。。。麻烦;了。。 谢谢啊。。高分送。。。




[解决办法]

SQL code
3.    基于图书馆数据库的3个表,用T-SQL语言完成一下操作:1)    查询全体图书的图书号、书名、作者、出版社和单价    select * from books2)    显示所有借阅者的读者号,并去掉重复行    select distinct 读者编号 from borrowinf3)    查询全体图书的信息,其中单价打8折,并设置该列的别名为‘打折价’    select book_id. book_name, book_aut, book_pre, 0.8*price as 打折价    from books
[解决办法]
SQL code
1、select book_id. book_name, book_aut, book_pre from books 2、select distinct reader_id from borrowinf 3、select *,price*0.8 as '打折价' from books 4、select * from books where price between 20 and 305、select * from books where book_pre in (N'机械工业出版社',N'科学出版社',N'人民邮电出版社')6、select * from books where book_pre not in(N'机械工业出版社',N'科学出版社出版社')7、select reader_id,reader_name from readers where reader_name like '_建'8、select reader_id,reader_name from readers where '[!王张李]%'9、select * from borrowinf where  yhdate is null or len(yhdate)=010、select reader_id from borrowinf where  ghdate> yhdate11、select avg(price)as '平均价格',max(price) as '最高价格',min(price) as '最低价格' from books where book_pre =N'机械工业出版社'12、select * from readers  r inner join borrowinf b on r.reader_id=b.reader_id inner join books bk on b.book_id=bk.book_id
[解决办法]
在7楼的基础上简化下
1、select * from books 
2、select distinct reader_id from borrowinf 
3、select *,price*0.8 as '打折价' from books 
4、select * from books where price between 20 and 30
5、select * from books where book_pre in (N'机械工业出版社',N'科学出版社',N'人民邮电出版社')
6、select * from books where book_pre not in(N'机械工业出版社',N'科学出版社出版社')
7、select reader_id,reader_name from readers where reader_name like '_建'
8、select reader_id,reader_name from readers where '[!王张李]%'
9、select * from borrowinf where yhdate is null or len(yhdate)=0
10、select reader_id from borrowinf where ghdate> yhdate
11、select avg(price)as '平均价格',max(price) as '最高价格',min(price) as '最低价格' from books where book_pre =N'机械工业出版社'
12、select * from readers r inner join borrowinf b on r.reader_id=b.reader_id
 inner join books bk on b.book_id=bk.book_id

热点排行