亚洲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  編輯:張佳奇
 

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元的銷售員編號、姓名和銷售額

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種商品的客戶編號、客戶名稱、商品編號、商品名稱、數(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ā)公司銷售相同的客戶編號、名稱和商品編號、商品名稱、數(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、查找表中所有姓劉的職工的工號,部門,薪水

select emp_no,emp_name,dept,salary

from employee

where emp_name like '劉%'

20、查找所有定單金額高于2000的所有客戶編號

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ù)部或會計(jì)部的女員工的基本信息

select emp_no,emp_name,dept

from employee

where sex='F'and dept in ('業(yè)務(wù)','會計(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

本新聞共4頁,當(dāng)前在第2頁  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筆記本模特寫真