Hello all,I added a sub-query to a temp table that was working prior to me adding the sub-query. Now that I've added the sub-query I am getting an incorrect syntax error with my join. I'm unsure as to what could be causing this. I've checked the query, and I don't have any commas out of place, and I'm pretty sure I have the parenthesis in the correct place, but the code just isn't working. I was hoping someone on this forum might be able to see something I can't.CREATE TABLE #TMPCSGACCT1 ( [ITEM#] NUMERIC (7,0), [SUB_ACCT_NO] VARCHAR (MAX), [CUST_ACCT_NO] VARCHAR (MAX), [ORDER_NUMB] VARCHAR (MAX))INSERT INTO #TMPCSGACCT1 (ITEM#,SUB_ACCT_NO,CUST_ACCT_NO,ORDER_NUMB)SELECT ITEM#, rtrim(ltrim([SUB_ACCT_NO])) as SUB_ACCT_NO, rtrim(ltrim([CUST_ACCT_NO])) as CUST_ACCT_NO, rtrim(ltrim([ORDER_NUMB])) as ORDER_NUMB FROM AuditGroup.dbo.Order_Num_Data3 (NOLOCK)SELECT A.ITEM#, A.SUB_ACCT_NO, A.CUST_ACCT_NO, A.ORDER_NUMB, B.PRIN_OJB, B.AGNT_OJB,B.JOB_TYP_OJB, B.COMPL_CDE_OJB, B.LS_CHG_OP_ID_OJB, B.LS_CHG_DTE_OJBINTO #TMP1CFROM #TMPCSGACCT1 AS A (NOLOCK) INNER JOIN Vantage.dbo.OJB_JOBS AS B (NOLOCK)ON A.ORDER_NUMB = B.ORDER_NO_OJBWHERE B.LS_CHG_DTE_OJB = (SELECT MAX(B.LS_CHG_DTE_OJB) AS LS_CHG_DTE_OJB FROM Vantage.dbo.OJB_JOBS AS C ON C.LS_CHG_DTE_OJB = B.LS_CHG_DTE_OJB)GROUP BY A.ITEM#, A.SUB_ACCT_NO, A.CUST_ACCT_NO, A.ORDER_NUMB, B.PRIN_OJB, B.AGNT_OJB,B.JOB_TYP_OJB, B.COMPL_CDE_OJB, B.LS_CHG_OP_ID_OJB, B.LS_CHG_DTE_OJB
Thank you in advance!Damian