成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

DB2數(shù)據(jù)庫必須掌握的常用語句(五)

數(shù)據(jù)庫
DB2數(shù)據(jù)庫主要應用于大型應用系統(tǒng),具有較好的可伸縮性,功能性也比較強大,受到很多用戶的喜愛,下面就為大家講述DB2數(shù)據(jù)庫必須掌握的常用語句。

DB2數(shù)據(jù)庫必須掌握的常用語句:

1、 求每位客戶訂購的每種產(chǎn)品的總數(shù)量及平均單價,并按客戶號,產(chǎn)品號從小到大排列

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

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

Select order_no

from sale_item

Group by order_no

Having count(*)>3

3、 查詢訂購的產(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))

4、 在sales表中查找出訂單金額大于"E0013業(yè)務員在1996/11/10這天所接每一張訂單的金額"的所有訂單,并顯示承接這些訂單的業(yè)務員和該訂單的金額

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')

5、 查詢末承接業(yè)務的員工的信息

Select *

From employee a

Where not exists

(select * from sales b where a.emp_no=b.sale_id)

6、 查詢來自上海市的客戶的姓名,電話、訂單號及訂單金額

Select cust_name,tel_no,order_no,tot_amt

From customer a ,sales b

Where a.cust_id=b.cust_id and addr='上海市'

7、 查詢每位業(yè)務員各個月的業(yè)績,并按業(yè)務員編號、月份降序排序

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

8、 求每種產(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

9、 查詢總訂購金額超過'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'))

10、 查詢業(yè)績***的的業(yè)務員號、業(yè)務員名及其總銷售金額

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)

11、 查詢每位客戶所訂購的每種產(chǎn)品的詳細清單,要求顯示出客戶號,客戶名,產(chǎn)品號,產(chǎn)品名,數(shù)量及單價

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

12、 求各部門的平均薪水,要求按平均薪水從小到大排序

select dept,avg(salary)

from employee

group by dept

order by avg(salary)

 

責任編輯:迎迎 來源: 天極網(wǎng)
相關(guān)推薦

2011-03-16 10:10:39

DB2數(shù)據(jù)庫常用命令

2011-03-16 10:39:11

DB2數(shù)據(jù)庫常用語句

2011-03-16 10:19:49

DB2數(shù)據(jù)庫常用語句

2011-03-16 10:12:14

DB2數(shù)據(jù)庫常用語句

2010-11-04 12:00:59

db2存儲過程

2010-08-09 13:08:45

DB2數(shù)據(jù)庫

2010-08-10 09:07:51

DB2數(shù)據(jù)庫優(yōu)化

2010-07-29 09:44:35

DB2數(shù)據(jù)庫優(yōu)化

2010-09-06 10:00:00

DB2數(shù)據(jù)庫

2010-08-25 15:13:22

DB2Oracle數(shù)據(jù)庫

2010-04-13 15:24:25

Oracle維護常用語

2011-03-11 16:02:03

DB2數(shù)據(jù)庫安裝

2011-08-31 16:33:00

DB2

2010-07-27 08:48:52

DB2數(shù)據(jù)庫優(yōu)化

2010-10-08 10:18:26

MySQL自增字段

2011-03-16 13:21:04

IBM DB2數(shù)據(jù)庫性能參數(shù)

2010-11-03 16:32:10

DB2創(chuàng)建數(shù)據(jù)庫

2010-08-31 17:34:46

DB2

2010-11-01 13:45:16

DB2數(shù)據(jù)庫的優(yōu)勢

2010-08-05 16:13:20

DB2數(shù)據(jù)庫
點贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 少妇一级淫片aaaaaaaaa | 精品国产乱码一区二区三 | 日韩av在线一区 | 日韩成年人视频在线 | 在线午夜 | 中文字字幕一区二区三区四区五区 | 中文字幕国产视频 | 99精品观看 | 欧洲亚洲视频 | 色久在线 | 99视频在线播放 | 精品久久久久久久久久久久久久久久久 | 日本成人久久 | 国产精品欧美一区二区三区不卡 | 一区二区三区在线观看视频 | 日本一区二区高清视频 | 爱高潮www亚洲精品 中文字幕免费视频 | 国产精品美女久久久久aⅴ国产馆 | 国产a一区二区 | 亚洲精品18 | 国产高清免费 | 草久久| 黄色免费av | 国产99视频精品免视看9 | 欧美三区 | 91一区二区三区在线观看 | 九九九国产 | 日日草夜夜草 | 日韩视频国产 | 毛片大全 | 国产精品一区二区久久 | 成人在线精品 | 日韩快播电影 | 亚洲视频免费 | 人人做人人澡人人爽欧美 | 韩日精品一区 | 99爱在线观看| 不卡视频在线 | 亚洲高清视频在线观看 | 国产精品av久久久久久久久久 | 午夜专区 |