西西軟件園多重安全檢測(cè)下載網(wǎng)站、值得信賴的軟件下載站!
軟件
軟件
文章
搜索
鐢熸椿鏈嶅姟
鏀粯瀹濋挶鍖�(Alipay)V10.2.53.7000 瀹夊崜鐗�鏀粯瀹濋挶鍖�(Alipay)V10.2.53.7000 瀹夊崜鐗�
鐧惧害鍦板浘瀵艰埅2022V15.12.10 瀹夊崜鎵嬫満鐗�鐧惧害鍦板浘瀵艰埅2022V15.12.10 瀹夊崜鎵嬫満鐗�
鎵嬫満娣樺疂瀹㈡埛绔痸10.8.40瀹樻柟鏈€鏂扮増鎵嬫満娣樺疂瀹㈡埛绔痸10.8.40瀹樻柟鏈€鏂扮増
鐣呴€旂綉鎵嬫満瀹㈡埛绔痸5.6.9 瀹樻柟鏈€鏂扮増鐣呴€旂綉鎵嬫満瀹㈡埛绔痸5.6.9 瀹樻柟鏈€鏂扮増
鍗冭亰鐭ヨ瘑鏈嶅姟appv4.5.1瀹樻柟鐗�鍗冭亰鐭ヨ瘑鏈嶅姟appv4.5.1瀹樻柟鐗�
褰遍煶鎾斁
p2psearcher瀹夊崜鐗�7.3  鎵嬫満鐗�p2psearcher瀹夊崜鐗�7.3 鎵嬫満鐗�
閰风嫍闊充箰2022瀹樻柟鐗圴11.0.8 瀹樻柟瀹夊崜鐗�閰风嫍闊充箰2022瀹樻柟鐗圴11.0.8 瀹樻柟瀹夊崜鐗�
鐖卞鑹烘墜鏈虹増v13.1.0鐖卞鑹烘墜鏈虹増v13.1.0
鐧惧害褰遍煶7.13.0 瀹樻柟鏈€鏂扮増鐧惧害褰遍煶7.13.0 瀹樻柟鏈€鏂扮増
褰遍煶鍏堥攱v6.9.0 瀹夊崜鎵嬫満鐗�褰遍煶鍏堥攱v6.9.0 瀹夊崜鎵嬫満鐗�
闃呰宸ュ叿
鑵捐鍔ㄦ极V9.11.5 瀹夊崜鐗�鑵捐鍔ㄦ极V9.11.5 瀹夊崜鐗�
涔︽棗灏忚鍏嶈垂鐗堟湰v11.5.5.153 瀹樻柟鏈€鏂扮増涔︽棗灏忚鍏嶈垂鐗堟湰v11.5.5.153 瀹樻柟鏈€鏂扮増
QQ闃呰鍣╝ppV7.7.1.910 瀹樻柟鏈€鏂扮増QQ闃呰鍣╝ppV7.7.1.910 瀹樻柟鏈€鏂扮増
鎳掍汉鐣呭惉鍚功appv7.1.5 瀹樻柟瀹夊崜鐗�鎳掍汉鐣呭惉鍚功appv7.1.5 瀹樻柟瀹夊崜鐗�
璧风偣璇讳功app鏂扮増鏈�20227.9.186 瀹夊崜鐗�璧风偣璇讳功app鏂扮増鏈�20227.9.186 瀹夊崜鐗�
閲戣瀺鐞嗚储
骞冲畨璇佸埜瀹塭鐞嗚储V9.1.0.1 瀹樻柟瀹夊崜鐗�骞冲畨璇佸埜瀹塭鐞嗚储V9.1.0.1 瀹樻柟瀹夊崜鐗�
娴烽€氳瘉鍒告墜鏈虹増(e娴烽€氳储)8.71 瀹樻柟瀹夊崜鐗�娴烽€氳瘉鍒告墜鏈虹増(e娴烽€氳储)8.71 瀹樻柟瀹夊崜鐗�
涓滄捣璇佸埜涓滄捣鐞嗚储4.0.5 瀹夊崜鐗�涓滄捣璇佸埜涓滄捣鐞嗚储4.0.5 瀹夊崜鐗�
涓摱璇佸埜绉诲姩鐞嗚储杞欢6.02.010 瀹樻柟瀹夊崜鐗�涓摱璇佸埜绉诲姩鐞嗚储杞欢6.02.010 瀹樻柟瀹夊崜鐗�
鍗庨緳璇佸埜灏忛噾鎵嬫満鐞嗚储杞欢3.2.4 瀹夊崜鐗�鍗庨緳璇佸埜灏忛噾鎵嬫満鐞嗚储杞欢3.2.4 瀹夊崜鐗�
鎵嬫満閾惰
绂忓缓鍐滄潙淇$敤绀炬墜鏈洪摱琛屽鎴风2.3.4 瀹夊崜鐗�绂忓缓鍐滄潙淇$敤绀炬墜鏈洪摱琛屽鎴风2.3.4 瀹夊崜鐗�
鏄撳埗浣滆棰戝壀杈慳pp4.1.16瀹夊崜鐗�鏄撳埗浣滆棰戝壀杈慳pp4.1.16瀹夊崜鐗�
鏀粯瀹濋挶鍖�(Alipay)V10.2.53.7000 瀹夊崜鐗�鏀粯瀹濋挶鍖�(Alipay)V10.2.53.7000 瀹夊崜鐗�
涓浗宸ュ晢閾惰鎵嬫満閾惰appV7.0.1.2.5 瀹夊崜鐗�涓浗宸ュ晢閾惰鎵嬫満閾惰appV7.0.1.2.5 瀹夊崜鐗�
涓浗閾惰鎵嬫満閾惰瀹㈡埛绔�7.2.5 瀹樻柟瀹夊崜鐗�涓浗閾惰鎵嬫満閾惰瀹㈡埛绔�7.2.5 瀹樻柟瀹夊崜鐗�
浼戦棽鐩婃櫤
鑵捐鐚庨奔杈句汉鎵嬫満鐗圴2.3.0.0 瀹樻柟瀹夊崜鐗�鑵捐鐚庨奔杈句汉鎵嬫満鐗圴2.3.0.0 瀹樻柟瀹夊崜鐗�
鍔茶垶鍥㈠畼鏂规鐗堟墜娓竩1.2.1瀹樻柟鐗�鍔茶垶鍥㈠畼鏂规鐗堟墜娓竩1.2.1瀹樻柟鐗�
楗ラタ椴ㄩ奔杩涘寲鏃犻檺閽荤煶鐗坴7.8.0.0瀹夊崜鐗�楗ラタ椴ㄩ奔杩涘寲鏃犻檺閽荤煶鐗坴7.8.0.0瀹夊崜鐗�
妞嶇墿澶ф垬鍍靛案鍏ㄦ槑鏄�1.0.91 瀹夊崜鐗�妞嶇墿澶ф垬鍍靛案鍏ㄦ槑鏄�1.0.91 瀹夊崜鐗�
鍔ㄤ綔灏勫嚮
鍦颁笅鍩庣獊鍑昏€卋t鐗�1.6.3 瀹樻柟鐗�鍦颁笅鍩庣獊鍑昏€卋t鐗�1.6.3 瀹樻柟鐗�
瑁呯敳鑱旂洘1.325.157 瀹夊崜鐗�瑁呯敳鑱旂洘1.325.157 瀹夊崜鐗�
鍦f枟澹槦鐭㈤泦缁搗4.2.1 瀹夊崜鐗�鍦f枟澹槦鐭㈤泦缁搗4.2.1 瀹夊崜鐗�
閬ぉ3D鎵嬫父1.0.9瀹夊崜鐗�閬ぉ3D鎵嬫父1.0.9瀹夊崜鐗�
濉旈槻娓告垙
瀹夊崜妞嶇墿澶ф垬鍍靛案2榛戞殫鏃朵唬淇敼鐗圴1.9.5 鏈€鏂扮増瀹夊崜妞嶇墿澶ф垬鍍靛案2榛戞殫鏃朵唬淇敼鐗圴1.9.5 鏈€鏂扮増
涔辨枟瑗挎父2v1.0.150瀹夊崜鐗�涔辨枟瑗挎父2v1.0.150瀹夊崜鐗�
淇濆崼钀濆崪3鏃犻檺閽荤煶鏈€鏂扮増v2.0.0.1 瀹夊崜鐗�淇濆崼钀濆崪3鏃犻檺閽荤煶鏈€鏂扮増v2.0.0.1 瀹夊崜鐗�
鍙h鑻遍泟鍗曟満鐗�1.2.0 瀹夊崜鐗�鍙h鑻遍泟鍗曟満鐗�1.2.0 瀹夊崜鐗�
灏忓皬鍐涘洟瀹夊崜鐗�2.7.4 鏃犻檺閲戝竵淇敼鐗�灏忓皬鍐涘洟瀹夊崜鐗�2.7.4 鏃犻檺閲戝竵淇敼鐗�
璧涜溅绔炴妧
鐧诲北璧涜溅2鎵嬫父1.47.1  瀹夊崜鐗�鐧诲北璧涜溅2鎵嬫父1.47.1 瀹夊崜鐗�
涓€璧锋潵椋炶溅瀹夊崜鐗坴2.9.14 鏈€鏂扮増涓€璧锋潵椋炶溅瀹夊崜鐗坴2.9.14 鏈€鏂扮増
璺戣窇鍗′竵杞︽墜鏈虹増瀹樻柟鏈€鏂扮増v1.16.2 瀹夊崜鐗�璺戣窇鍗′竵杞︽墜鏈虹増瀹樻柟鏈€鏂扮増v1.16.2 瀹夊崜鐗�
鐙傞噹椋欒溅8鏋侀€熷噷浜戜慨鏀圭増(鍏嶆暟鎹寘)v4.6.0j 閲戝竵鏃犻檺鐗�鐙傞噹椋欒溅8鏋侀€熷噷浜戜慨鏀圭増(鍏嶆暟鎹寘)v4.6.0j 閲戝竵鏃犻檺鐗�
鐧句箰鍗冪偖鎹曢奔2021鏈€鏂扮増5.78 瀹夊崜鐗�鐧句箰鍗冪偖鎹曢奔2021鏈€鏂扮増5.78 瀹夊崜鐗�
瑙掕壊鎵紨
姊﹀够鍓戣垶鑰呭彉鎬佺増1.0.1.2瀹夊崜鐗�姊﹀够鍓戣垶鑰呭彉鎬佺増1.0.1.2瀹夊崜鐗�
浠欏浼犺ro澶嶅叴瀹夊崜鐗�1.20.3鏈€鏂扮増浠欏浼犺ro澶嶅叴瀹夊崜鐗�1.20.3鏈€鏂扮増
姊﹀够璇涗粰鎵嬫父鐗�1.3.6 瀹樻柟瀹夊崜鐗�姊﹀够璇涗粰鎵嬫父鐗�1.3.6 瀹樻柟瀹夊崜鐗�
鐜嬭€呰崳鑰€V3.72.1.1 瀹夊崜鏈€鏂板畼鏂圭増鐜嬭€呰崳鑰€V3.72.1.1 瀹夊崜鏈€鏂板畼鏂圭増
璋佸灏忚溅寮烘墜鏈虹増v1.0.49 瀹夊崜鐗�璋佸灏忚溅寮烘墜鏈虹増v1.0.49 瀹夊崜鐗�
绯荤粺杞欢
mac纾佺洏鍒嗗尯宸ュ叿(Paragon Camptune X)V10.8.12瀹樻柟鏈€鏂扮増mac纾佺洏鍒嗗尯宸ュ叿(Paragon Camptune X)V10.8.12瀹樻柟鏈€鏂扮増
鑻规灉鎿嶄綔绯荤粺MACOSX 10.9.4 Mavericks瀹屽叏鍏嶈垂鐗�鑻规灉鎿嶄綔绯荤粺MACOSX 10.9.4 Mavericks瀹屽叏鍏嶈垂鐗�
Rar瑙e帇鍒╁櫒mac鐗坴1.4 瀹樻柟鍏嶈垂鐗�Rar瑙e帇鍒╁櫒mac鐗坴1.4 瀹樻柟鍏嶈垂鐗�
Mac瀹夊崜妯℃嫙鍣�(ARC Welder)v1.0 瀹樻柟鏈€鏂扮増Mac瀹夊崜妯℃嫙鍣�(ARC Welder)v1.0 瀹樻柟鏈€鏂扮増
Charles for MacV3.9.3瀹樻柟鐗�Charles for MacV3.9.3瀹樻柟鐗�
缃戠粶宸ュ叿
鎼滅嫍娴忚鍣╩ac鐗坴5.2 瀹樻柟姝e紡鐗�鎼滅嫍娴忚鍣╩ac鐗坴5.2 瀹樻柟姝e紡鐗�
閿愭嵎瀹㈡埛绔痬ac鐗圴1.33瀹樻柟鏈€鏂扮増閿愭嵎瀹㈡埛绔痬ac鐗圴1.33瀹樻柟鏈€鏂扮増
蹇墮mac鐗坴1.3.2 瀹樻柟姝e紡鐗�蹇墮mac鐗坴1.3.2 瀹樻柟姝e紡鐗�
鏋佺偣浜旂瑪Mac鐗�7.13姝e紡鐗�鏋佺偣浜旂瑪Mac鐗�7.13姝e紡鐗�
濯掍綋宸ュ叿
Apple Logic Pro xV10.3.2Apple Logic Pro xV10.3.2
Adobe Premiere Pro CC 2017 mac鐗坴11.0.0 涓枃鐗�Adobe Premiere Pro CC 2017 mac鐗坴11.0.0 涓枃鐗�
鍗冨崈闈欏惉Mac鐗圴9.1.1 瀹樻柟鏈€鏂扮増鍗冨崈闈欏惉Mac鐗圴9.1.1 瀹樻柟鏈€鏂扮増
Mac缃戠粶鐩存挱杞欢(MacTV)v0.121 瀹樻柟鏈€鏂扮増Mac缃戠粶鐩存挱杞欢(MacTV)v0.121 瀹樻柟鏈€鏂扮増
Adobe Fireworks CS6 Mac鐗圕S6瀹樻柟绠€浣撲腑鏂囩増Adobe Fireworks CS6 Mac鐗圕S6瀹樻柟绠€浣撲腑鏂囩増
鍥惧舰鍥惧儚
AutoCAD2015 mac涓枃鐗堟湰v1.0 瀹樻柟姝e紡鐗�AutoCAD2015 mac涓枃鐗堟湰v1.0 瀹樻柟姝e紡鐗�
Adobe Photoshop cs6 mac鐗坴13.0.3 瀹樻柟涓枃鐗�Adobe Photoshop cs6 mac鐗坴13.0.3 瀹樻柟涓枃鐗�
Mac鐭㈤噺缁樺浘杞欢(Sketch mac)v3.3.2 涓枃鐗�Mac鐭㈤噺缁樺浘杞欢(Sketch mac)v3.3.2 涓枃鐗�
Adobe After Effects cs6 mac鐗坴1.0涓枃鐗�Adobe After Effects cs6 mac鐗坴1.0涓枃鐗�
Adobe InDesign cs6 mac1.0 瀹樻柟涓枃鐗�Adobe InDesign cs6 mac1.0 瀹樻柟涓枃鐗�
搴旂敤杞欢
Mac鐗堝揩鎾�1.1.26 瀹樻柟姝e紡鐗圼dmg]Mac鐗堝揩鎾�1.1.26 瀹樻柟姝e紡鐗圼dmg]
Mac璇诲啓NTFS(Paragon NTFS for Mac)12.1.62 瀹樻柟姝e紡鐗�Mac璇诲啓NTFS(Paragon NTFS for Mac)12.1.62 瀹樻柟姝e紡鐗�
杩呴浄10 for macv3.4.1.4368 瀹樻柟鏈€鏂扮増杩呴浄10 for macv3.4.1.4368 瀹樻柟鏈€鏂扮増
Mac涓嬫渶寮哄ぇ鐨勭郴缁熸竻鐞嗗伐鍏�(CleanMyMac for mac)v3.1.1 姝e紡鐗�Mac涓嬫渶寮哄ぇ鐨勭郴缁熸竻鐞嗗伐鍏�(CleanMyMac for mac)v3.1.1 姝e紡鐗�
鑻规灉BootCamp5.1.5640 瀹樻柟鏈€鏂扮増鑻规灉BootCamp5.1.5640 瀹樻柟鏈€鏂扮増

首頁(yè)西西教程數(shù)據(jù)庫(kù)教程 → sql 多表查詢 Select語(yǔ)句查詢實(shí)例分析

sql 多表查詢 Select語(yǔ)句查詢實(shí)例分析

相關(guān)文章發(fā)表評(píng)論 來(lái)源:本站整理時(shí)間:2010/6/10 15:46:15字體大�。�A-A+

作者:綠色軟件編輯點(diǎn)擊:3192次評(píng)論:1次標(biāo)簽: Select

  • 類型:音頻播放大�。�2.0M語(yǔ)言:中文 評(píng)分:5.0
  • 標(biāo)簽:
立即下載

-1、查找員工的編號(hào)、姓名、部門和出生日期,如果出生日期為空值,
--顯示日期不詳,并按部門排序輸出,日期格式為yyyy-mm-dd。
select emp_no ,emp_name ,dept ,
isnull(convert(char(10),birthday,120),'日期不詳') birthday
from employee
order by dept

--2、查找與喻自強(qiáng)在同一個(gè)單位的員工姓名、性別、部門和職稱
select emp_no,emp_name,dept,title
from employee
where emp_name<>'喻自強(qiáng)' and dept in
(select dept from employee
where emp_name='喻自強(qiáng)')

--3、按部門進(jìn)行匯總,統(tǒng)計(jì)每個(gè)部門的總工資
select dept,sum(salary)
from employee
group by dept

--4、查找商品名稱為14寸顯示器商品的銷售情況,
--顯示該商品的編號(hào)、銷售數(shù)量、單價(jià)和金額
select a.prod_id,qty,unit_price,unit_price*qty totprice
from sale_item a,product b
where a.prod_id=b.prod_id and prod_name='14寸顯示器'

--5、在銷售明細(xì)表中按產(chǎn)品編號(hào)進(jìn)行匯總,統(tǒng)計(jì)每種產(chǎn)品的銷售數(shù)量和金額
select prod_id,sum(qty) totqty,sum(qty*unit_price) totprice
from sale_item
group by prod_id

--6、使用convert函數(shù)按客戶編號(hào)統(tǒng)計(jì)每個(gè)客戶1996年的訂單總金額
select cust_id,sum(tot_amt) totprice
from sales
where convert(char(4),order_date,120)='1996'
group by cust_id

--7、查找有銷售記錄的客戶編號(hào)、名稱和訂單總額
select a.cust_id,cust_name,sum(tot_amt) totprice
from customer a,sales b
where a.cust_id=b.cust_id
group by a.cust_id,cust_name

--8、查找在1997年中有銷售記錄的客戶編號(hào)、名稱和訂單總額
select a.cust_id,cust_name,sum(tot_amt) totprice
from customer a,sales b
where a.cust_id=b.cust_id and convert(char(4),order_date,120)='1997'
group by a.cust_id,cust_name

--9、查找一次銷售最大的銷售記錄
select order_no,cust_id,sale_id,tot_amt
from sales
where tot_amt=
(select max(tot_amt)
from sales)

--10、查找至少有3次銷售的業(yè)務(wù)員名單和銷售日期
select emp_name,order_date
from employee a,sales b
where emp_no=sale_id and a.emp_no in
(select sale_id
from sales
group by sale_id
having count(*)>=3)
order by emp_name

--11、用存在量詞查找沒(méi)有訂貨記錄的客戶名稱
select cust_name
from customer a
where not exists
(select *
from sales b
where a.cust_id=b.cust_id)

--12、使用左外連接查找每個(gè)客戶的客戶編號(hào)、名稱、訂貨日期、訂單金額
--訂貨日期不要顯示時(shí)間,日期格式為yyyy-mm-dd
--按客戶編號(hào)排序,同一客戶再按訂單降序排序輸出
select a.cust_id,cust_name,convert(char(10),order_date,120),tot_amt
from customer a left outer join sales b on a.cust_id=b.cust_id
order by a.cust_id,tot_amt desc

--13、查找16M DRAM的銷售情況,要求顯示相應(yīng)的銷售員的姓名、
--性別,銷售日期、銷售數(shù)量和金額,其中性別用男、女表示
select emp_name 姓名, 性別= case a.sex when 'm' then '男'
when 'f' then '女'
else '未'
end,
銷售日期= isnull(convert(char(10),c.order_date,120),'日期不詳'),
qty 數(shù)量, qty*unit_price as 金額
from employee a, sales b, sale_item c,product d
where d.prod_name='16M DRAM' and d.prod_id=c.prod_id and
a.emp_no=b.sale_id and b.order_no=c.order_no

--14、查找每個(gè)人的銷售記錄,要求顯示銷售員的編號(hào)、姓名、性別、
--產(chǎn)品名稱、數(shù)量、單價(jià)、金額和銷售日期
select emp_no 編號(hào),emp_name 姓名, 性別= case a.sex when 'm' then '男'
when 'f' then '女'
else '未'
end,
prod_name 產(chǎn)品名稱,銷售日期= isnull(convert(char(10),c.order_date,120),'日期不詳'),
qty 數(shù)量, qty*unit_price as 金額
from employee a left outer join sales b on a.emp_no=b.sale_id , sale_item c,product d
where d.prod_id=c.prod_id and b.order_no=c.order_no

--15、查找銷售金額最大的客戶名稱和總貨款
select cust_name,d.cust_sum
from customer a,
(select cust_id,cust_sum
from (select cust_id, sum(tot_amt) as cust_sum
from sales
group by cust_id ) b
where b.cust_sum =
( select max(cust_sum)
from (select cust_id, sum(tot_amt) as cust_sum
from sales
group by cust_id ) c )
) d
where a.cust_id=d.cust_id

--16、查找銷售總額少于1000元的銷售員編號(hào)、姓名和銷售額
select emp_no,emp_name,d.sale_sum
from employee a,
(select sale_id,sale_sum
from (select sale_id, sum(tot_amt) as sale_sum
from sales
group by sale_id ) b
where b.sale_sum <1000
) d
where a.emp_no=d.sale_id

--17、查找至少銷售了3種商品的客戶編號(hào)、客戶名稱、商品編號(hào)、商品名稱、數(shù)量和金額
select a.cust_id,cust_name,b.prod_id,prod_name,d.qty,d.qty*d.unit_price
from customer a, product b, sales c, sale_item d
where a.cust_id=c.cust_id and d.prod_id=b.prod_id and
c.order_no=d.order_no and a.cust_id in (
select cust_id
from (select cust_id,count(distinct prod_id) prodid
from (select cust_id,prod_id
from sales e,sale_item f
where e.order_no=f.order_no) g
group by cust_id
having count(distinct prod_id)>=3) h )

--18、查找至少與世界技術(shù)開發(fā)公司銷售相同的客戶編號(hào)、名稱和商品編號(hào)、商品名稱、數(shù)量和金額
select a.cust_id,cust_name,d.prod_id,prod_name,qty,qty*unit_price
from customer a, product b, sales c, sale_item d
where a.cust_id=c.cust_id and d.prod_id=b.prod_id and
c.order_no=d.order_no and not exists
(select f.*
from customer x ,sales e, sale_item f
where cust_name='世界技術(shù)開發(fā)公司' and x.cust_id=e.cust_id and
e.order_no=f.order_no and not exists
( select g.*
from sale_item g, sales h
where g.prod_id = f.prod_id and g.order_no=h.order_no and
h.cust_id=a.cust_id)
)

19、查找表中所有姓劉的職工的工號(hào),部門,薪水
select emp_no,emp_name,dept,salary
from employee
where emp_name like '劉%'

20、查找所有定單金額高于2000的所有客戶編號(hào)
select cust_id
from sales
where tot_amt>2000

21、統(tǒng)計(jì)表中員工的薪水在4000-6000之間的人數(shù)
select count(*)as 人數(shù)
from employee
where salary between 4000 and 6000

22、查詢表中的同一部門的職工的平均工資,但只查詢"住址"是"上海市"的員工
select avg(salary) avg_sal,dept
from employee
where addr like '上海市%'
group by dept

23、將表中住址為"上海市"的員工住址改為"北京市"
update employee
set addr like '北京市'
where addr like '上海市'

24、查找業(yè)務(wù)部或會(huì)計(jì)部的女員工的基本信息。
select emp_no,emp_name,dept
from employee
where sex='F'and dept in ('業(yè)務(wù)','會(huì)計(jì)')

25、顯示每種產(chǎn)品的銷售金額總和,并依銷售金額由大到小輸出。
select prod_id ,sum(qty*unit_price)
from sale_item
group by prod_id
order by sum(qty*unit_price) desc

26、選取編號(hào)界于'C0001'和'C0004'的客戶編號(hào)、客戶名稱、客戶地址。
select CUST_ID,cust_name,addr
from customer
where cust_id between 'C0001' AND 'C0004'

27、計(jì)算出一共銷售了幾種產(chǎn)品。
select count(distinct prod_id) as '共銷售產(chǎn)品數(shù)'
from sale_item

28、將業(yè)務(wù)部員工的薪水上調(diào)3%。
update employee
set salary=salary*1.03
where dept='業(yè)務(wù)'

29、由employee表中查找出薪水最低的員工信息。
select *
from employee
where salary=
(select min(salary )
from employee )

30、使用join查詢客戶姓名為"客戶丙"所購(gòu)貨物的"客戶名稱","定單金額","定貨日期","電話號(hào)碼"
select a.cust_id,b.tot_amt,b.order_date,a.tel_no
from customer a join sales b
on a.cust_id=b.cust_id and cust_name like '客戶丙'

31、由sales表中查找出訂單金額大于"E0013業(yè)務(wù)員在1996/10/15這天所接每一張訂單的金額"的所有訂單。
select *
from sales
where tot_amt>all
(select tot_amt
from sales
where sale_id='E0013'and order_date='1996/10/15')
order by tot_amt

32、計(jì)算'P0001'產(chǎn)品的平均銷售單價(jià)
select avg(unit_price)
from sale_item
where prod_id='P0001'

33、找出公司女員工所接的定單
select sale_id,tot_amt
from sales
where sale_id in
(select sale_id from employee
where sex='F')

34、找出同一天進(jìn)入公司服務(wù)的員工
select a.emp_no,a.emp_name,a.date_hired
from employee a
join employee b
on (a.emp_no!=b.emp_no and a.date_hired=b.date_hired)
order by a.date_hired

35、找出目前業(yè)績(jī)超過(guò)232000元的員工編號(hào)和姓名。
select emp_no,emp_name
from employee
where emp_no in
(select sale_id
from sales
group by sale_id
having sum(tot_amt)<232000)

36、查詢出employee表中所有女職工的平均工資和住址在"上海市"的所有女職工的平均工資
select avg(salary)
from employee
where sex like 'f'
union
select avg(salary)
from employee
where sex like 'f' and addr like '上海市%'

37、在employee表中查詢薪水超過(guò)員工平均薪水的員工信息。
Select *
from employee
where salary>( select avg(salary)
from employee)

38、 找出目前銷售業(yè)績(jī)超過(guò)10000元的業(yè)務(wù)員編號(hào)及銷售業(yè)績(jī),并按銷售業(yè)績(jī)從大到小排序。
Select sale_id ,sum(tot_amt)
from sales
group by sale_id
having sum(tot_amt)>10000
order by sum(tot_amt) desc

39、 找出公司男業(yè)務(wù)員所接且訂單金額超過(guò)2000元的訂單號(hào)及訂單金額。
Select order_no,tot_amt
From sales ,employee
Where sale_id=emp_no and sex='M' and tot_amt>2000

40、 查詢sales表中訂單金額最高的訂單號(hào)及訂單金額。
Select order_no,tot_amt from sales
where tot_amt=(select max(tot_amt) from sales)

41、 查詢?cè)诿繌堄唵沃杏嗁?gòu)金額超過(guò)4000元的客戶名及其地址。
Select cust_name,addr from customer a,sales b
where a.cust_id=b.cust_id and tot_amt>4000

42、 求出每位客戶的總訂購(gòu)金額,顯示出客戶號(hào)及總訂購(gòu)金額,并按總訂購(gòu)金額降序排列。
Select cust_id,sum(tot_amt) from sales
Group by cust_id
order by sum(tot_amt) desc

43、 求每位客戶訂購(gòu)的每種產(chǎn)品的總數(shù)量及平均單價(jià),并按客戶號(hào),產(chǎn)品號(hào)從小到大排列。
Select cust_id,prod_id,sum(qty),sum(qty*unit_price)/sum(qty)
From sales a, sale_item b
Where a.order_no=b.order_no
Group by cust_id,prod_id
order by cust_id,prod_id

44、 查詢訂購(gòu)了三種以上產(chǎn)品的訂單號(hào)。
Select order_no
from sale_item
Group by order_no
Having count(*)>3

45、 查詢訂購(gòu)的產(chǎn)品至少包含了訂單3號(hào)中所訂購(gòu)產(chǎn)品的訂單。
Select distinct order_no
From sale_item a
Where order_no<>'3'and not exists (
Select * from sale_item b where order_no ='3' and not exists
(select * from sale_item c where c.order_no=a.order_no and c.prod_id=b.prod_id))

46、 在sales表中查找出訂單金額大于"E0013業(yè)務(wù)員在1996/11/10這天所接每一張訂單的金額"的所有訂單,并顯示承接這些訂單的業(yè)務(wù)員和該訂單的金額。
Select sale_id,tot_amt from sales
where tot_amt>all(select tot_amt
from sales
where sale_id='E0013' and order_date='1996-11-10')

47、 查詢末承接業(yè)務(wù)的員工的信息。
Select *
From employee a
Where not exists
(select * from sales b where a.emp_no=b.sale_id)

48、 查詢來(lái)自上海市的客戶的姓名,電話、訂單號(hào)及訂單金額。
Select cust_name,tel_no,order_no,tot_amt
From customer a ,sales b
Where a.cust_id=b.cust_id and addr='上海市'

49、 查詢每位業(yè)務(wù)員各個(gè)月的業(yè)績(jī),并按業(yè)務(wù)員編號(hào)、月份降序排序。
Select sale_id,month(order_date), sum(tot_amt)
from sales
group by sale_id,month(order_date)
order by sale_id,month(order_date) desc

50、 求每種產(chǎn)品的總銷售數(shù)量及總銷售金額,要求顯示出產(chǎn)品編號(hào)、產(chǎn)品名稱,總數(shù)量及總金額,并按產(chǎn)品號(hào)從小到大排列。
Select a.prod_id,prod_name,sum(qty),sum(qty*unit_price)
From sale_item a,product b
Where a.prod_id=b.prod_id
Group by a.prod_id,prod_name
order by a.prod_id
51、 查詢總訂購(gòu)金額超過(guò)'C0002'客戶的總訂購(gòu)金額的客戶號(hào),客戶名及其住址。
Select cust_id, cust_name,addr
From customer
Where cust_id in (select cust_id from sales
Group by cust_id
Having sum(tot_amt)>
(Select sum(tot_amt) from sales where cust_id='C0002'))

52、 查詢業(yè)績(jī)最好的的業(yè)務(wù)員號(hào)、業(yè)務(wù)員名及其總銷售金額。
select emp_no,emp_name,sum(tot_amt)
from employee a,sales b
where a.emp_no=b.sale_id
group by emp_no,emp_name
having sum(tot_amt)=
(select max(totamt)
from (select sale_id,sum(tot_amt) totamt
from sales
group by sale_id) c)

53、 查詢每位客戶所訂購(gòu)的每種產(chǎn)品的詳細(xì)清單,要求顯示出客戶號(hào),客戶名,產(chǎn)品號(hào),產(chǎn)品名,數(shù)量及單價(jià)。
select a.cust_id, cust_name,c.prod_id,prod_name,qty, unit_price
from customer a,sales b, sale_item c ,product d
where a.cust_id=b.cust_id and b.order_no=c.order_no and c.prod_id=d.prod_id

54、 求各部門的平均薪水,要求按平均薪水從小到大排序。
select dept,avg(salary)
from employee
group by dept
order by avg(salary)

    相關(guān)評(píng)論

    閱讀本文后您有什么感想? 已有人給出評(píng)價(jià)!

    • 8 喜歡喜歡
    • 3 頂
    • 1 難過(guò)難過(guò)
    • 5 囧
    • 3 圍觀圍觀
    • 2 無(wú)聊無(wú)聊

    熱門評(píng)論

    最新評(píng)論

    第 1 樓 北京開心網(wǎng) 網(wǎng)友 客人 發(fā)表于: 2011/2/11 11:26:40
    沒(méi)有表呀!!!!!

    支持( 0 ) 蓋樓(回復(fù))

    發(fā)表評(píng)論 查看所有評(píng)論(1)

    昵稱:
    表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
    字?jǐn)?shù): 0/500 (您的評(píng)論需要經(jīng)過(guò)審核才能顯示)