赛迪网 > IT技术 数据库 > DB2开发者园地
  IT资讯搜索
 
IT产品搜索
[程序开发][网管世界][网络安全][数据库技术]
[操作系统][嘉宾聊天·在线访谈][活动集锦]
[精彩专题][Symantec专区][订阅IT技术周刊]
[开发论坛][网管论坛][安全论坛][数据库论坛]
[操作系统论坛][Sybase专区][IBM dW技术专区]
[病毒求助][病毒与漏洞播报][文档·源码下载]

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

发布时间:2008.05.09 04:48     来源:赛迪网    作者: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

<<上一页 1 2 3 4 下一页>>


[ 发表评论 ] 字体[  ] [ 打印 ] [ 进入博客 ] [ 进入论坛 ]  [ 推荐给朋友 ]
  相关文章
· 带你深入了解IBM DB2数据库的备份与恢复 (05-08) · 解决IBM DB2数据库锁等待的相关问题 (05-07)
· 轻松解决IBM DB2数据库锁等待的相关问题 (05-07) · 讲解DB2数据库性能调整的十个实用技巧 (05-07)
· 教你快速掌握IBM DB2数据库的性能参数 (05-07) · 讲解IBM DB2数据库性能调整的相关命令 (05-07)
· 讲解DB2数据库性能调整的十个实用技巧 (05-07) · 锁现象通常分为死锁和锁等待两种情形 (04-24)
· 实例讲解DB2数据库中SELECT语句高级用法 (04-22) · 在DB2数据库中很难理解的catalog单词 (04-17)
  客户需求反馈表
* 姓  名:
更多资料  了解方案  认识厂商
* 单位名称:
* 联系电话:
* 电子邮件:
  赛迪推荐  
  手机·资费 ·新品·导购·评测·手机资费·宽带
手机搜索  诺基亚 N73 MOTO Z6
  IT产品 ·笔记本·台式机·服务器·打印·投影
IT产品搜索 
  IT技术 ·开发·网管·安全·数据库·操作系统
  信息化 ·热点·专题·访谈·周刊·方案案例
· 移动信息化市场方兴未艾 企业呼唤标准出台
· 如何把握企业价值差异 避免CRM与SCM脱节
· 齐看四大厂商的SaaS动态 ERP案例分析
· 通方期货CRM解决方案 方正电子公文系统
  IT博客 ·曾剑秋·项立刚·Java学习·网管
  IT技术论坛 ·开发·网管·安全·数据库·系统