4张表怎么查询
有如下表:
create table 中心(
中心编号 int(11) not null primary key,
中心名称 varchar(50) not null
)character set utf8;
create table 部门(
部门编号 int(11) not null primary key,
部门名称 varchar(50) not null,
所属中心 int(11) not null
)character set utf8;
create table 被考核员工
员工编号 int(11) not null primary key,
员工姓名 varchar(50) not null,
所属部门 int(11) not null
)character set utf8;
create table 违规记录(
编号 int(11) not null auto_increment primary key,
员工编号 int(11) not null,
考核月份 int(11) not null,
奇次打卡结算次数 int(11),
奇次扣款数 int(11),
迟到(或早退)次数 int(11),
迟到(或早退)分钟数 int(11),
迟到(或早退)扣款数 int(11),
未出勤结算天数 int(11),
未出勤扣款数 int(11),
本月合计扣款数 int(11) not null
)character set utf8;
我现在查询出了如下的结果(所有有违规记录的员工记录):
select
员工姓名,
sum(迟到(或早退)次数) as 迟到次数,
sum(迟到(或早退)分钟数) as 总迟到分钟数,
sum(迟到(或早退)扣款数) as 迟到总扣款数,
sum(奇次打卡结算次数) as 奇次打卡数,
sum(奇次扣款数) as 奇次扣款数,
sum(未出勤结算天数) as 未出勤天数,
sum(未出勤扣款数) as 未出勤扣款数,
sum(本月合计扣款数) as 合计扣款数
from
违规记录,
被考核员工
where
被考核员工.员工编号 = 违规记录.员工编号
group by 员工姓名
order by 合计扣款数 desc;
问:怎么查询出所有被考核人员的情况(包括有违规和没有违规的),并且在结果中显示出这个员工所属部门和所属中心名称。