


下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、在MSSQL2000pub數(shù)據(jù)庫下,完成下面的作業(yè),分別寫出SQL語句。1、查找在美國的所有出版商select * from publishers where country=,USAT2、查找在法國巴黎的出版商名字select pub_name from publishers where country=1Francefand city=,Paris,3、查找所有價庶大于20美元的出版物的名字select title from titles where price154、查找在2000年出版的出版物記錄select * from titles where pubdate between 20
2、00lland 20001231 23:59:595、查找出版物名稱中含有“computer”字樣的出版物。select * from titles where title like % computer %6、查找在美國、所在州不為空的出版商記錄select * from publishers where country=US Aand state is not null7、在MSSQLServer2000的pub數(shù)據(jù)庫下,查找出版商的pubJd為1389,的出版物的名字,價格,以及 出版日期,結(jié)果按出版時間降序排列。select title,price,pubdate from title
3、s where pub_id=,1389, order by pubdate desc 8、在MSSQLServer2000的pub數(shù)據(jù)庫下,查找出版商品pubJd為3389,的出版物的數(shù)量,最大價格, 平均價格,總價格(一種刊物一份的總價)。生成的表的列名分別為數(shù)量最大價格,平均價格,總 價格。select count()數(shù)量,max(price)最大價格,avg(price)平均價格,sum(price)總價格 from titles where pub_id=n1389n9、仿照上題,查找所有出版商的出版物的數(shù)量,最大價格,平均價格,總價格,并列出各出版商的pub.ido 按照出版物的數(shù)
4、量對結(jié)果排序。select pub_id,count(*)數(shù)量,max(price)最大價格,avg(price)平均價格,sum(price)總價格 from titlesgroup by pub_idorder by 數(shù)量1()、查詢所有出版商的姓名,及其發(fā)行物的種類。(一種刊物算一個種類)select pub_name,count(title)from publishers left outer join titleson publishers.pub_id=titles.pub_idgroup by pub_name11、查詢比所看的出版物平均價格高的出版物名稱以及價格。select
5、title,price from titleswhere price(select avg(price) from titles)12、查詢美國出版商發(fā)行的刊物名稱。select title from titleswhere pub_id in(select pub_id from publishers where country=,USAt)或select title from titles,publisherswhere titles.pub_id=publishers.pub_id and country=,USA613、查詢比pubjd為389而出版物所有價格都高的出版物名稱,價格。s
6、elect title,price from titles where priceAll(select price from titles where pub_id=t1389,)春詢比pubjd為1389,的某一出版物價格高的出版物名稱,價格。select title,price from titles where priceany(select price from titles where pub_id=,1389,)14、分別查詢pub_id為P877,與“38夕的出版物,并返回一個結(jié)果集。(用union)select * from titles where pub_id=0877un
7、ionselect * from titles where pub_id=,1389,15、在出版商中插入記錄9909?夫連理工大學(xué)出版社?dalian;nun:chininsert into publishers(pub_id,pub_name,city,state,country) vahies(99O9;大連理工大 學(xué)出版社;daliannuHdiina,)或insert into publishers vahiesC9909;大連理工大學(xué)出版社?dalianniilldiiiia,)16、將pub_id為,0877,與“38夕的出版商的出版物價格均升5美元,出版日期設(shè)為2002-09-
8、09。update titlesset price=price+5,pubdate=,2002-09-09,where pubjd in(1389,0877)或update titlesset price=price+5,pubdate=,2002-09-09,where pub_id =,1389,or pub_id=,0877117、刪除pubjd為9909的出版嗇記錄delete from publishers where pub_id=,9909618、查詢沒有出版物的出版商記錄select * from publishers where pub_id not in(select di
9、stinct pub_id from titles)19、定義一個視圖,反映的是各個出版商名稱以及出版物數(shù)目。(不顯示沒有值版物的出版商)create view v_pub_counts asselect pub_name,count(*) as countfrom publishers,titleswhere publishers.pub_id=titles.pub_idgroup by pub_name2()、定義一個視圖,反映的是各個出版商名稱以及出版物數(shù)目。(顯示沒有出版物的出版商)create view pubsum asselect pub_name,count(title) as
10、 pub_countfrom publishers left outer join titleson publishers.pub_id=titles.pub_id group by pub_name21、統(tǒng)計(jì)每種遜 (type)刊物的刊物數(shù)目(每條titles記錄為1條),并只輸出刊物數(shù)目大于2的記錄。 select type,count(title)from titlesgroup by typehaving count(title)222、查詢出版了所有類型(type)刊物的出版商姓名。方法一:select pub_namefrom publisherswhere not exists(
11、select *from (select distinct type from titles) twhere not existsselect *from titleswhere(titles.type=t.type) and(titles.pub_id=publishers.pub_id)方法二:select pub_namefrom publisherswhere not exists(select distinct type from titles twherenot existsselect *from titleswhere(titles.type=t.type) and(titles.pub_id=publishers
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 人教A版高一(下)數(shù)學(xué)必修第二冊6.2.3向量的數(shù)乘運(yùn)算【教學(xué)設(shè)計(jì)】
- 六年級上冊數(shù)學(xué)教案:第2單元-第5課時 分?jǐn)?shù)混合運(yùn)算練習(xí)(2) 北師大版
- 《上學(xué)時間》(教案)2024-2025學(xué)年數(shù)學(xué)二年級下冊
- 一年級數(shù)學(xué)下冊教案-4.3 動手做(二)2-北師大版
- 《找規(guī)律》(教案)三年級下冊數(shù)學(xué)北師大版
- 一年級上數(shù)學(xué)教案-認(rèn)識物體(7)-西師大版
- 第十章浮力單元教學(xué)設(shè)計(jì) 2023-2024學(xué)年人教版八年級下冊物理
- 2024年人工心肺機(jī)項(xiàng)目資金籌措計(jì)劃書代可行性研究報告
- 河北隆化縣第二中學(xué)人教版八年級上冊歷史與社會第三單元第一課 秦始皇開創(chuàng)大一統(tǒng)教學(xué)設(shè)計(jì)
- 2025年吉林省延邊朝鮮族自治州單招職業(yè)適應(yīng)性測試題庫審定版
- 2025年中華工商時報社事業(yè)單位招聘12人歷年高頻重點(diǎn)模擬試卷提升(共500題附帶答案詳解)
- 安全生產(chǎn)事故調(diào)查與案例分析(第3版)課件 呂淑然 第1-4章 緒論-應(yīng)急預(yù)案編制與應(yīng)急管理
- 《職業(yè)技能等級評價規(guī)范編制指南編制說明》
- 《教育強(qiáng)國建設(shè)規(guī)劃綱要(2024-2035年)》解讀講座
- 2024-2025學(xué)年廣東省深圳市寶安區(qū)高一(上)期末數(shù)學(xué)試卷(含答案)
- 畜禽養(yǎng)殖場惡臭污染物排放及其處理技術(shù)研究進(jìn)展
- 超聲內(nèi)鏡引導(dǎo)下穿刺活檢術(shù)的配合及護(hù)理
- 同濟(jì)大學(xué)《線性代數(shù)》-課件
- 新生兒常見的產(chǎn)傷及護(hù)理
- 申請兩癌補(bǔ)助申請書
- 香港審計(jì)合同范例
評論
0/150
提交評論