我想知道您是否可以提供帮助 - 我已经创建了一个 SQL 查询(SQLServer),尽管没有显示一些结果,我认为这是由于某些连接上的 NULL 结果。例如,我知道一些连接将使用 NULL 结果,因为 100.resp_unit_no 和 100.employee_no 一样可能是 NULL。
到目前为止的查询是:
select
058.DESCRIPTION "IRU",
111.job_ref "Job Reference",
117.DESCRIPTION "Status",
108.STATUS "Fixed?",
105.DESCRIPTION "Job Type",
111.POSTCODE "Postcode",
111.site_id "Site ID",
108.CONTRACT_START "Contract Earliest",
108.CONTRACT_COMPLETION "Contract Latest",
108.BOOKED_DURATION "Planned Duration (mins)",
111.IMPORTANCE "Importance",
111.CUSTOMER_NAME "Customer Name",
100.expected_start "Expected Start",
100.expected_end "Expected End",
210.NAME "Employee",
111.ON_HOLD "On Hold?"
FROM
111_JOBS 111,
108_JOB_DETAILS 108,
058_RESPONSIBILITY_UNITS 058,
100_ACTIVITIES 100,
105_ACTIVITY_TYPES 105,
210_EMPLOYEES 210,
117_STATUS_DESCRIPTIONS 117
where 111.JOB_NO=108.JOB_NO
AND 111.JOB_NO=100.JOB_NO
AND 100.RESP_UNIT_NO=058.RESP_UNIT_NO
AND 111.JOB_TYPE=105.ACTIVITY_TYPE
AND 210.EMPLOYEE_NO=100.EMPLOYEE_NO
AND 117.STATUS=100.ACTIVITY_STATUS
order by IRU, Employee, EXPECTED_START;
我想我需要一个正确的外部连接,但我不能完全正确地得到结构......
任何帮助将不胜感激!