sql question - outer join seems not to work

前端 未结 3 807
无人共我
无人共我 2021-01-24 06:38

using: sql server

Here is what I am trying to accomplish. I have two tables one with 70 companies (company info, etc) and one table recording the incident numbers of tho

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-24 07:02

    You need make to corrections:

    • change the RIGHT OUTER JOIN to a LEFT JOIN.
    • add an OR TTS_INCIDENTS.TS_COMPANYID is null to the WHERE clause

    modifying the join is going to put the priority on all COMPANIES, instead of all INCIDENTS, as you have it now.
    modifying the WHERE clause will allow Comapnies with NO INCIDENTS to also show-up in the list.

提交回复
热议问题