I have duplicate records except date in a table.. Each record has the case# four times.. I want to put the latest case# in a temp table..
How can I get the case numbers with the max date inserted into a temp table? See my code below..
The error i get is:
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
Select * INTO ##tblCB
(SELECT * FROM CORE.tblStatusTracking ST
WHERE nCaseID IN ( select distinct st.nCaseID, Max(st.dtCreatedDate) from CTS.CORE.tblCase c inner join CTS.CORE.tblStatusTracking st
On c.nCaseID = t.nCaseID
inner join CTS.CORE.tblCD_AR_CaseInfo ci on c.nCaseID = ci.nCaseID
inner join CTSApp.app.tblOracleCustomers oc
on ci.sCustID = oc.ACCOUNT_NUMBER
where c.nUserID_PrimaryAgent = 5402
and c.bClosed = 0
and CUSTOMER_TYPE = 'NP & SS'
group by st.nCaseID)