45IT.COM- 电脑学习从此开始!
DIY硬件教程攒机经验装机配置
设计Photoshop网页设计特效
系统注册表DOS系统命令其它
存储主板显卡外设键鼠内存
维修显卡CPU内存打印机
WinXPVistaWin7unix/linux
CPU光驱电源/散热显示器其它
修技主板硬盘键鼠显示器光驱
办公ExcelWordPowerPointWPS
编程数据库CSS脚本PHP
网络局域网QQ服务器
软件网络系统图像安全
页面导航: 首页 > 设计学院 > 网络编程 > 数据库 >

学习DB2数据库必须掌握的五十四条常用语句(3)

电脑软硬件应用网 45IT.COM 时间:2008-05-09 16:04 作者:Bert

26、选取编号界于'C0001'和'C0004'的客户编号、客户名称、客户地址

select CUST_ID,cust_name,addr

from customer

where cust_id between 'C0001' AND 'C0004'

27、计算出一共销售了几种产品

select count(distinct prod_id) as '共销售产品数'

from sale_item

28、将业务部员工的薪水上调3%

update employee

set salary=salary*1.03

where dept='业务'

29、由employee表中查找出薪水最低的员工信息

select *

from employee

where salary=

(select min(salary )

from employee )

30、使用join查询客户姓名为"客户丙"所购货物的"客户名称","定单金额","定货日期","电话号码"

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业务员在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、计算'P0001'产品的平均销售单价

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、找出同一天进入公司服务的员工

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、找出目前业绩超过232000元的员工编号和姓名

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表中查询薪水超过员工平均薪水的员工信息

Select *

from employee

where salary>( select avg(salary)

from employee)

38、 找出目前销售业绩超过10000元的业务员编号及销售业绩,并按销售业绩从大到小排序

Select sale_id ,sum(tot_amt)

from sales

group by sale_id

having sum(tot_amt)>10000

order by sum(tot_amt) desc

39、 找出公司男业务员所接且订单金额超过2000元的订单号及订单金额

Select order_no,tot_amt

From sales ,employee

Where sale_id=emp_no and sex='M' and tot_amt>2000

顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
无法在这个位置找到: baidushare.htm
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
验证码:点击我更换图片
推荐知识