亚洲AV无码乱码在线观看不卡|最新大伊香蕉精品视频在线|亚洲不卡av一区二区|国产美女无遮挡免费

登錄論壇 | 注冊會員 設(shè)為首頁 | 收藏本站
當(dāng)前位置 : 首頁>軟件學(xué)院>數(shù)據(jù)庫>SQL>正文
 
學(xué)習(xí)DB2數(shù)據(jù)庫必須掌握的五十四條常用語句

http://m.yibo1263.com 2008/5/12 8:19:06  來源:ccident  編輯:張佳奇
 

Group by cust_id,prod_id

Order by cust_id,prod_id

44、 查詢訂購了三種以上產(chǎn)品的訂單號

Select order_no

from sale_item

Group by order_no

Having count(*)>3

45、 查詢訂購的產(chǎn)品至少包含了訂單3號中所訂購產(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、 查詢來自上海市的客戶的姓名,電話、訂單號及訂單金額

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è)績,并按業(yè)務(wù)員編號、月份降序排序

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)品編號、產(chǎn)品名稱,總數(shù)量及總金額,并按產(chǎn)品號從小到大排列

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、 查詢總訂購金額超過'C0002'客戶的總訂購金額的客戶號,客戶名及其住址

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è)績最好的的業(yè)務(wù)員號、業(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、 查詢每位客戶所訂購的每種產(chǎn)品的詳細(xì)清單,要求顯示出客戶號,客戶名,產(chǎn)品號,產(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)

本新聞共4頁,當(dāng)前在第4頁  1  2  3  4  

收藏】【打印】【進(jìn)入論壇
  相關(guān)文章:

·金倉護(hù)航電力應(yīng)用數(shù)據(jù)表超越國外數(shù)據(jù)庫
·IBM收購數(shù)據(jù)庫安全公司Guardium
·IBM或斥資2.25億美元收購數(shù)據(jù)庫安全軟件廠商
·解決數(shù)據(jù)庫開發(fā)中的疑難問題
·快速了解服務(wù)器數(shù)據(jù)庫系統(tǒng)的優(yōu)點(diǎn) 
·教你為數(shù)據(jù)庫服務(wù)器配置存儲和內(nèi)存
·數(shù)據(jù)庫服務(wù)器安全的權(quán)限控制策略
·長期使用中型Access數(shù)據(jù)庫的一點(diǎn)經(jīng)驗(yàn)
·教你簡便實(shí)現(xiàn)Oracle數(shù)據(jù)庫文件移動方法
·網(wǎng)站整體優(yōu)化之?dāng)?shù)據(jù)庫優(yōu)化
·Dreamweaver中數(shù)據(jù)庫路徑的使用

 
 
 
最新文章

搶先蘋果,消息稱英特爾芯片采用臺積電
三星揭曉業(yè)內(nèi)首款單條 512GB DDR5 內(nèi)存
vivo 高端新機(jī)爆料:120Hz 曲面屏 + 天
vivo Y21 在印度正式上市:Helio P35 芯
微星推出 GeForce RTX 3080 Sea Hawk X
消息稱三星 Galaxy Tab S8 系列平板將放
機(jī)械革命推出 F6 輕薄本:16 英寸全面屏
英特爾 12 代 Alder Lake CPU 600 系列
雷軍:向小米手機(jī) 1 首批用戶每人贈送價(jià)
小米李明談用戶被踢出 MIUI 測試版:大

推薦文章
1
2
3
4
5
6
7
8
9
10
叛逆嫩模性感寫真
宮如敏不雅照瘋傳 看張馨予韓一菲獸獸誰
不懼孔子搶位 阿凡達(dá)游戲影音配置推薦
2015第十七屆“東北安博會”火爆招商
第十六屆東北國際公共安全防范產(chǎn)品博覽
2016年第五屆中國國際商業(yè)信息化博覽會
2016年第五屆中國國際POS機(jī)及相關(guān)設(shè)備展
互聯(lián)網(wǎng)電視熟了嗎 2013最火電視深解析
桑達(dá)獲邀出席2015中國(廣州)國際POS機(jī)
寶獲利報(bào)名參加“2015年度中國POS機(jī)行業(yè)
八卦圖解 More>>
叛逆嫩模性感寫真 宮如敏不雅照瘋傳 看張馨予韓一菲
周偉童魔鬼身材日本性感寫真圖  聯(lián)想V360筆記本模特寫真