0
我有一個SQL Server查詢:優化一個SQL Server查詢
(
SELECT k12_dms_contacts_institution_jobtitles.job_title_id AS id
FROM k12_dms_contacts_institution_jobtitles
INNER JOIN k12_dms_institution_master ON k12_dms_institution_master.id = k12_dms_contacts_institution_jobtitles.inst_id
WHERE (
k12_dms_institution_master.state_id='63'
AND k12_dms_contacts_institution_jobtitles.glevel_id='1'
)
GROUP BY
k12_dms_contacts_institution_jobtitles.job_title_id
)
INTERSECT
(
SELECT k12_dms_contacts_institution_jobtitles.job_title_id AS id
FROM k12_dms_contacts_institution_jobtitles
INNER JOIN k12_dms_institution_master ON k12_dms_institution_master.id = k12_dms_contacts_institution_jobtitles.inst_id
WHERE (
k12_dms_institution_master.state_id='63'
AND k12_dms_contacts_institution_jobtitles.glevel_id='2'
)
GROUP BY
k12_dms_contacts_institution_jobtitles.job_title_id
)
INTERSECT
(
SELECT k12_dms_contacts_institution_jobtitles.job_title_id AS id
FROM k12_dms_contacts_institution_jobtitles
INNER JOIN k12_dms_institution_master ON k12_dms_institution_master.id = k12_dms_contacts_institution_jobtitles.inst_id
WHERE (
k12_dms_institution_master.state_id='63'
AND k12_dms_contacts_institution_jobtitles.glevel_id='3'
)
GROUP BY
k12_dms_contacts_institution_jobtitles.job_title_id
)
INTERSECT
(
SELECT k12_dms_contacts_institution_jobtitles.job_title_id AS id
FROM k12_dms_contacts_institution_jobtitles
INNER JOIN k12_dms_institution_master ON k12_dms_institution_master.id = k12_dms_contacts_institution_jobtitles.inst_id
WHERE (
k12_dms_institution_master.state_id='63'
AND k12_dms_contacts_institution_jobtitles.glevel_id='4'
)
GROUP BY
k12_dms_contacts_institution_jobtitles.job_title_id
)
有什麼辦法來優化上述query.Intersection只需要在哪裏clause.I想獲取所有的 的基礎上,所有職等都通用的職位。
不,我只是想取得所有職系通用的職稱。 – user1163513