Hello all,I'm trying to add a sub-query to my initial query, and I continue to receive the error Incorrect Syntax error. I've tried rearranging my join placements, but I continue to receive the error. I was wondering if anyone could take a look at my query to see if they can see where I'm going wrong. I appreciate any and all help.IF OBJECT_ID('TEMPDB..#TMP1C') IS NOT NULL DROP TABLE #TMP1Cselect distinct T.PRIN_MON, T.AGNT_MON, T.SUB_ACCT_NO_MON, s.RES_NAME_SBB,hs.ADDR1_HSE,hs.RES_CITY_HSE,hs.RES_STATE_HSE,hs.POSTAL_CDE_HSE,T.TRAN_DTE_MON, --T.TRAN_CDE_MON, T.TRAN_AMT_MON, s.CUR_BAL_SBB,case when h.acct_stage_ohi = 'v' then 'VOL_DISCO' when h.ACCT_STAGE_OHI = 'n' then 'NON_PAY_DISCO'ELSE '' END AS 'CUSTOMER_STATUS',h.connect_dte_ohi, h.disco_dte_ohi, h.item_status_ohiINTO #TMP1Cfrom vantage.dbo.ohi_hist_item as h (nolock),Vantage.dbo.SBB_BASE as s (nolock),Vantage.dbo.HSE_BASE as hs (nolock),vantage.dbo.MON_TRAN_BASE as T (nolock)AND h.PRIN_OHI = s.PRIN_SBBand h.SYS_OHI = s.SYS_SBBand h.SUB_ACCT_NO_OHI = s.SUB_ACCT_NO_SBBand s.HSE_KEY_SBB = hs.HSE_KEY_HSEand t.PRIN_MON = h.PRIN_OHIand t.sub_acct_no_mon = h.sub_acct_no_ohiwhere H.DISCO_DTE_OHI = (select max(disco_dte_ohi) as disco_dte_ohi FROM Vantage.dbo.OHI_HIST_ITEM AS B WHERE B.CUST_ACCT_NO_OHI = H.CUST_ACCT_NO_OHI)and T.TRAN_CDE_MON = '287'and h.acct_stage_ohi in ('V','N')and h.ITEM_STATUS_OHI NOT IN ('B','X')group by T.PRIN_MON, T.AGNT_MON, T.SUB_ACCT_NO_MON,s.RES_NAME_SBB,hs.ADDR1_HSE,hs.RES_CITY_HSE,hs.RES_STATE_HSE,hs.POSTAL_CDE_HSE, T.TRAN_DTE_MON, --T.TRAN_CDE_MON, T.TRAN_AMT_MON, s.CUR_BAL_SBB,h.CUSTOMER_STATUS,h.connect_dte_ohi, h.disco_dte_ohi, h.item_status_ohiSELECT A.*, EQ.eqp_stat_eqp, eq.EQP_SERIAL_EQPFROM #TMP1C AS A (NOLOCK) left outer JOIN vantage.dbo.EQP_BASE as EQ (nolock)ON h.SUB_ACCT_NO_OHI = EQ.EQP_LOCAL_EQPgroup by A.PRIN_MON, A.AGNT_MON, A.SUB_ACCT_NO_MON,A.RES_NAME_SBB,A.ADDR1_HSE,A.RES_CITY_HSE,A.RES_STATE_HSE,A.POSTAL_CDE_HSE, A.TRAN_DTE_MON, --T.TRAN_CDE_MON, A.TRAN_AMT_MON, A.CUR_BAL_SBB,EQ.eqp_stat_eqp,eq.EQP_SERIAL_EQP, A.acct_stage_ohi,A.connect_dte_ohi, A.disco_dte_ohi, A.item_status_ohi
Damian