通过以下查询,我得到50个结果:
SELECT count(*) AS total_num, TS_NAME
FROM TS_COMPANIES RIGHT OUTER JOIN TTS_INCIDENTS
ON (TS_COMPANIES.TS_ID=TTS_INCIDENTS.TS_COMPANYID AND TS_LEVEL2TECH=0)
WHERE TS_ACTIVEINACTIVE = 0 AND (TS_INCIDENTTYPE=10 OR TS_INCIDENTTYPE=11)
GROUP BY TS_NAME
ORDER BY TS_NAME
但是如果从ON子句中删除TS_LEVEL2TECH = 0,我会得到70个结果。
如何过滤TS_LEVEL2TECH = 0并仍然获得70个结果?
答案 0 :(得分:0)
这是不明确的,因为你并没有真正说TS_LEVEL2TECH来自哪里,TS_COMPANIES或TTS_INCIDENTS,一些表别名在这里真的有用。 (同样适用于TS_NAME等)