两个表,表一employees 字段:employees_id, employees_name, salay, department_id 其中employees_id是主键,department_id是外键
表二 department 字段:department_id ,department_name ,location 其中department_id是主键我想查询每个每个部门的编号,部门名称,部门人员的平均收入,然后排序。请各位大侠帮帮忙。
表二 department 字段:department_id ,department_name ,location 其中department_id是主键我想查询每个每个部门的编号,部门名称,部门人员的平均收入,然后排序。请各位大侠帮帮忙。
解决方案 »
- literal does not match format string
- 开发人员----》DBA或者数据库系统工程师发展
- 有什么书是讲关于Oracle的效率的
- 大侠们,存储过程参数问题,急!!!!!!!!
- 求一条Sql语句,横表转纵表!!!
- asp.net2.0+c#连接ORACLE问题,解决即散分
- 请问为某表的某字段创建序列号 sequence 后它会自动成为索引吗?
- 高手请帮忙!BLOB字段存储着byte数组,sql文查询条件是第一个byte为0x13。请问如何写sql文。
- 请教ASP如何连接远程Oracle?
- 在DBA Studio中如何察看数据库中的内容?
- 大表删除?
- 请问如何实现数据表之间的数据替换
--try it
select e.department_id,d.department_name ,sum(e.salay)/count(1) as ave_salay from employees e,department d where e.department_id=d.department_id group by e.department_id,d.department_name
from employees a,department b
where a.department_id=b.department_id
group by b.department_id,b.department_name,a.employees_name
order by a.salay;
弄错了。
select b.department_id 部门编号,b.department_name 部门名称,a.employees_name 员工姓名,sum(a.salay)/count(1) 部门人员平均收入
from employees a,department b
where a.department_id=b.department_id
group by b.department_id,b.department_name,a.employees_name
order by a.salay;
from employees a,department b
where a.department_id = b.department_id
group by b.department_id,b.department_name
select
department.department_id,
department.department_name,
avg(employees.salay)
from
employees,department
where
department.department_id= employees.department_id
group by
department.department_id
order by
department.department_id