April 4, 2011 at 7:07 am
Hi There,
I am using the query below to Left joint two tables. The problem is that the Left Join is creating over 200K lines of duplicates - which includes an amount field. Does there seem to be an obvious problem? Basically, I want to capture all of the lines in the AP INVOICES ALL LINES table to include the fields in Invoice7.
Let me know if I need to clarify!
SELECT DISTINCT A.[INVOICE_ID]
,A.[LINE_NUMBER]
,A.[LINE_TYPE_LOOKUP_CODE]
,A.[REQUESTER_ID]
,A.[DESCRIPTION]
,A.[LINE_SOURCE]
,A.[ORG_ID]
,A.[ITEM_DESCRIPTION]
,A.[ACCOUNT_SEGMENT]
,A.[BALANCING_SEGMENT]
,A.[COST_CENTER_SEGMENT]
,A.[OVERLAY_DIST_CODE_CONCAT]
,A.[DEFAULT_DIST_CCID]
,A.[ACCOUNTING_DATE]
,A.[PERIOD_NAME]
,A.[AMOUNT]
,A.[CANCELLED_FLAG]
,A.[PO_HEADER_ID]
,A.[PO_LINE_ID]
,A.[PO_DISTRIBUTION_ID]
,A.[EXPENDITURE_TYPE]
,A.[ATTRIBUTE_CATEGORY]
,A.[PURCHASING_CATEGORY_ID]
,A.[PRODUCT_TYPE]
,A.[PRODUCT_CATEGORY]
,B.VENDOR_ID
,B.PO_HEADER_DESC_PO
,B.INVOICE_DATE
,B.PO_ITEM_CATEGORY
,B.PO_ITEM_CATEGORY_1
,B.PO_ITEM_CATEGORY_2
,B.VENDOR_SITE_ID
,B.POSTING_STATUS
,B.DOC_CATEGORY_CODE
INTO INVOICE8
from [AP INVOICES ALL LINES] A
LEFT JOIN INVOICE7 B
ON A.INVOICE_ID = B.INVOICE_ID
April 4, 2011 at 7:16 am
Take a look at the article linked in my signature line and you will find out what is needed to post a question properly.
We don't have enough information to answer your question.
Post the missing info and you'll see answers coming.
-- Gianluca Sartori
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply