我正在使用左连接来组合两个表。它们是SOP10100
和SOP10106
。
合并两张表后,我必须得到两张发票(行)。现在我收到四张发票(行)。
你能看看我的查询并指出我在哪里犯了错误吗?
Select
DISTINCT DETAIL.SOPNUMBE as Invoice,
DETAIL.DOCDATE as Date,
DETAIL.CUSTNMBR as 'Customer Id',
DETAIL.CUSTNAME as Customer_Name,
DETAIL.SUBTOTAL as Sub_Total,
DETAIL.FRTAMNT as Freight,
DETAIL.TAXAMNT as Tax,
DETAIL.DOCAMNT AS 'Doc_Amount',
CASE when USRDEF05 <> ' ' THEN USRDEF05 ELSE '0'END as Winsys
FROM SOP10100 DETAIL
Left JOIN SOP10106 USERDEF
ON USERDEF.soptype = DETAIL.soptype
WHERE BACHNUMB ='WINSYS112012'