-1
在下面,我試圖選擇第一部分中選擇的數據,不應該存在於發票表中。我們希望不開發票。選擇行,如果訂單#不在第三個表中
# part 1
CREATE VIEW Stock.CLSPAYB2 AS
SELECT T02.OHCOM#, T02.oHPTTC, T02.oHSLR#, T01.OTTRT, T01.OTORD#, T02.ohord#, T01.OTTRND, T02.oHORDT, T02.oHordd, T02.ohttn$, t02.OHHLDC, T01.OTUSRN, T01.OTTRNC
FROM Sales.OETRANOT T01 INNER JOIN Stock.OEORHDOH T02
ON
T01.OTCOM# = T02.oHCOM#
AND
T01.OTORD# = T02.oHORD#
WHERE
T01.OTTRNC IN ('BCS')
AND
t02.ohordd >= 20150101
# Part 2. Here is the issue:
AND t02.ohord#
NOT IN
(
SELECT * FROM
Stock.OEINHDIH t03
WHERE t02.ohord# = t03.IHORD#
);