I have the following. I have a table called Customer that has the following data for example:
CustId CustDate CustOrdAmount CustGrpAmount
1 9/2/2014 1000.00 900.00
1 10/1/2014 800.00 800.00
1 11/2/2014 900.00 100.00
2 8/4/2014 990.00 990.00
2 9/5/2014 700.00 800.00
I then have another temp table I will create that will have the following:
What I need to do is check based on the CustId if the temp table CustOrdAmount delta is different OR the CustGrpAmount is different than the Max(CustDate) record in Customer for that CustId then Insert a new record into the Customer Table otherwise ignore the insert from the Temp table to the Customer table for that CustId.
So in this case above I would be comparing the 3rd record in Customer table CustId = 1 to the TempTable CustId = 1 and inserting a record into the Customer table. For CustId = 2 I would be ignoring that insert they are the same both columns.
Microsoft SQL Server
8/22/2022 - Mon
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst