部門表(deptcode:部門編號,deptname:部門名稱)員工表(humancode:員工編號,humanname:員工姓名,deptcode:部門編號)
考核表(resultcode:結果編號,humancode:人員編號,kpicode:考核結果---分 不合格,合格,優秀)
1.統計各部門合格的人數;
2.統計考核結果情況;
3.統計部門考核結果情況;
相應的sql
1.select count(*),c.deptname
from 考核表 a
inner join 員工表 b on a.humancode=b.humancode
inner join 部門表 c on b.deptcode=c.deptcode
where a.kpicode<>'不合格'
group by ,c.deptname
2.統計各部門所有員工的考核情況select a.*,b.*,c.*
from 考核表 a
inner join 員工表 b on a.humancode=b.humancode
inner join 部門表 c on b.deptcode=c.deptcode
第三題是:部門 合格 不合格 優秀
測試部 1 2 0
開發部 3 0 2
select count(*),a.kpicode,c.deptname
from 考核表 ainner join 員工表 b on a.humancode=b.humancode
inner join 部門表 c on b.deptcode=c.deptcode
group by ,c.deptname,a.kpicode
三張表的Left Join查詢
三張表 a id,b id,c id,要根據相同的id顯示三張表,做left join。select from a left join b on a.id b.id left join c on a.id c.id where b.id is notnull from條件後面的括號不能忘了。再分享一...
三張表的Left Join查詢
三張表 a id,b id,c id,要根據相同的id顯示三張表,做left join。select from a left join b on a.id b.id left join c on a.id c.id where b.id is notnull from條件後面的括號不能忘了。三張表 ...
三張表查詢 求解決問題??
table 學生資訊表 student,課程表 course,選課資訊表 subject drop table student commit create table student 學員表 stu number varchar 8 primary key not null,學員編號 stu nam...