CREATE TABLE EMP
(EMPNO NUMBER(4) NOT NULL,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7, 2),
COMM NUMBER(7, 2),
DEPTNO NUMBER(2))
emp表是employee 雇员信息表
empno 就是雇员的员工编号, employee number
ename 员工姓名, emlployee name
job 员工的工作是什么比如推销员,经理等
mgr 上级编号
hiredate受雇日期
sal薪金
comm佣金
deptno部门编号
SELECTmain.dept_name as 部门名称,
count(*) as 在职员工数,
sum(acu_salary) as 实发工资总额
FROM
dept main
INNER JOIN emp a ON main.dept_code = a.dept_code
INNER JOIN salary b ON a.emp_id = b.emp_id
WHERE
-- 1为有效标识
main.alive_flag = '1'
AND a.alive_flag = '1'
AND b.alive_flag = '1'
AND b.`month` = '201101'
GROUP BY
a.dept_code
HAVING
count(*) >5
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)