使用SQL語句完成下列題目
1、查詢圖書館中所有圖書的詳細資訊。(BookInfo表)
1 |
|
2、查詢所有圖書的圖書編號、圖書名稱和圖書價格。
1 |
|
3、 查詢所有圖書的圖書編號、圖書名稱和圖書總額。
1 |
b_id 編號,b_name 名稱,b_price*b_quantity 價格 from bookinfo |
4、查詢所有圖書的圖書編號、圖書名稱和總價值,但希望以漢字標題圖書編號、圖書名稱和總價值表示b_ID、b_Name和b_Price*b_Quantity。
1 |
|
5、查詢所有圖書中的“劉志成”編寫的圖書的所有資訊。
1 |
|
6、 查詢圖書類別編號為“17”,圖書價格在25~30元之間的圖書資訊,要求以漢字標題顯示圖書編號、圖書名稱、圖書類別編號和圖書價格。
1 |
where bt_id = 17 and b_price between 25 and 30; |
7、 查詢所有入庫在5年以上並且圖書價格在10~20之間的圖書的名稱、圖書作者、圖書價格和入庫時間(用“入庫時長”表示,該列不是基本表中的欄位,是計算出來的列)。
1 2 3 4 5 6 7 |
|
8、 查詢所有入庫在5年以上並且圖書價格不在10~20之間的圖書的名稱、圖書作者、圖書價格和入庫時間
1 2 3 4 5 6 7 |
|
9、查詢出版社編號為“001”和“003”的圖書詳細資訊。
1 |
|
10、查詢圖書名稱中包含“資料庫”字樣的圖書的詳細資訊。
1 |
|
11、查詢姓“王”且名字中有3個漢字的讀者的編號、讀者的姓名及可借書數量。
1 2 3 |
|
12、查詢暫時沒有圖書封面圖片的圖書資訊。
1 |
|
13、 通過圖書管理系統查詢借閱圖書的讀者編號,如果一個讀者借閱了多本圖書,只需要顯示一次讀者編號。
1 |
|
14、查詢前5行圖書的詳情資訊。
1 |
|
15、查詢前20%行圖書的詳情資訊。
1 2 3 4 5 |
|
16、查詢圖書出版社編號為“001”的圖書的圖書編號、圖書名稱、圖書價格和出版社編號,並要求根據圖書價格進行降序排列。
1 2 3 4 5 |
|
17、查詢價格在20元以上的圖書的圖書編號、圖書名稱、圖書價格和出版社編號的資訊,並要求按出版社編號升序排列;如果是同一出版社的圖書,則按價格降序排列。
1 2 3 |
|
18、查詢圖書館中每一個出版社的圖書種類數。
1 2 3 4 5 6 7 |
|
19、查詢圖書館中每一個出版社的圖書種類數及圖書總數。
1 2 3 4 5 6 7 |
|
20、分組後的資料按圖書總數進行降序排列。
1 2 3 4 5 6 7 |
|
21、對分組後的資料進行篩選,要求顯示圖書總量大於15的出版社編號、圖書種類和圖書總數,篩選後的結果按“圖書總數”升序排列。
1 2 3 4 5 6 7 8 9 |
|
22、查詢每種圖書的圖書編號、圖書名稱和圖書型別名稱(不是圖書類別編號)。
1 2 3 4 5 |
|
1 2 3 4 5 |
|
23、查詢借還表中所有“未還”圖書的借閱ID、借閱人(讀者)、圖書名稱、詳細存放位置和借出日期。
1 2 3 4 5 6 7 8 9 10 11 |
|
24、查詢不低於《JSP程式設計安全教程》價格的圖書編號、圖書名稱和圖書價格,查詢後的結果要求按圖書價格升序排列。
1 2 3 4 5 6 7 |
|
1 2 3 4 5 6 7 |
|
25、查詢所有圖書類別及其對應圖書資訊,如果該圖書類別沒有對應圖書也需要顯示其類別資訊。將BookType表和BookInfo表進行左外連線,BookType為左表,BookInfo表為右表。
1 2 3 4 5 6 7 |
|
26、查詢所有圖書的資訊(即使是不存在對應的圖書類別資訊,實際上這種情況是不存在的)。
1 2 3 4 5 |
|
27、查詢和《UML使用者指南》為同一出版社的圖書的圖書編號、圖書名稱和出版社編號。
1 2 3 4 5 |
|
28、查詢借閱了《SQL Server 2005例項教程》的借閱號、借閱日期和操作員。
1 2 3 4 5 |
|
1 2 3 4 5 6 7 8 9 |
|
29、查詢比出版社編號為“007”任一圖書入庫日期晚的圖書資訊,查詢結果按降序排列。
1 2 3 4 5 6 7 8 9 |
|
1 2 3 4 5 6 7 |
|
30、針對ReadInfo表中的每一位讀者,在BorrowReturn表中查詢借閱過圖書並且圖書狀態為“已還”的所有借閱資訊。
1 2 3 4 5 6 7 8 9 |
|
31、求每一類別圖書的平均價格,並將結果儲存到資料庫中。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
32、將圖書管理系統中的圖書出版社名稱為“機械工業出版社”的圖書的數量加1.
1 2 3 4 5 |
|
33、刪除出版社名稱為“機械工業出版社”的所有圖書資訊。
1 2 3 4 5 |
|