学习DB2数据库必须掌握的五十四条常用语句
2009-05-18 16:15:11 来源:WEB开发网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
40、 查询sales表中订单金额最高的订单号及订单金额
Select order_no,tot_amt from sales
where tot_amt=(select max(tot_amt) from sales)
更多精彩
赞助商链接