March 7, 2018 at 9:44 am
#temp_1 returns 50,000 with probably 3000 unique part numbers.
Now i need to make another temp table from our pricing table that has MILLIONS of parts with many different change dates.
I want temp_2 to only insert the parts that were in #Temp_1. I tried this. . . but i still get all rows from ZATS
thanks select * into #TEMP_1 FROM --this returns the correct data)
(
SELECT DISTINCT h.Customs_Entry_Num
,CAST(l.Entry_Line_ID AS INT) AS Entry_Line_ID
,h.Broker_Invoice
,h.Entry_Type
,l.Part_Num
,l.HTS_Num
,CAST(l.entry_date AS DATE) AS [Entry_Date]
FROM ADHOC.ATS_ESH h
INNER JOIN ADHOC.ATS_ESL l
ON h.TRANS_SK = l.TRANS_SK
WHERE h.Importer = 'FORD'
AND h.Entry_Date > (GETDATE() - 40)
AND l.HTS_Num NOT LIKE '98%'
AND l.Part_Num <> 'NPN'
AND h.Com_Desc_Code = 'Parts'
AND SUBSTRING(l.Part_Num, 4, 1) <> 'Z'
) as ENTRY
select * into #TEMP_2 FROM
(
SELECT DISTINCT
z.COMPOSITE_PART ----this is a column from pricing i want
,dateadd(d, 0, datediff(d, 0, CREATED_DATE)) As DateOnly --this is the change date
,z.HTS_NUMBER --treat this a the price
FROM TSI.ZATS_BROKER_FEED z
Left Join #TEMP_1
ON #TEMP_1.PART_NUM = Z.COMPOSITE_PART
WHERE Z.SUB_ORG = 'FORD'
) as ZATS
March 7, 2018 at 9:48 am
Can you post some DDL for the tables that you are pulling data from (Note the link in my signature line for best practices on getting help)
-- Itzik Ben-Gan 2001
March 7, 2018 at 9:51 am
Well that subquery for temp table 2 is using a left join not an inner join to temp table 1.
Also, caps lock cruise control for cool.
March 7, 2018 at 9:53 am
I dont know what a DDL is . .. I just need the COMPOSITE PARTS from ZATS that match the PART_NUMs in #TEMP1 . . . . . sorry, very new to this.
The columns in question are all Varchar(255) if that helps.
thanks again
March 7, 2018 at 10:27 am
Solved, our data is whacked . . . we have 500,000 rows in pricing for the 7000 distinct parts in temp 1
thanks
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply