I would really like some help on this, I'm befuddled. In the table, mwlCustomField, a LoanApp_ID could have multiple rows. What I am trying to do is loop through the rows, find the ones with the same LoanApp_ID, determine which record was last entered by comparing the DateValue, and only return the record that was last entered. This stored procedure only returns one record that has the lastest DateValue. I need this for each record....
Clear as mud?
FROM mwlLoanApp INNER JOIN
mwlBorrower ON mwlLoanApp.ID = mwlBorrower.LoanAPP_ID INNER JOIN
mwlCustomField ON mwlLoanApp.ID = mwlCustomField.LoanApp_ID
WHERE (mwlCustomField.DateValue =
(SELECT MAX(DateValue) AS Expr1
FROM mwlCustomField AS mwlCustomField_1
WHERE (CustFieldDef_ID = '768CA20DB9CF492AB633A919DFC5EA48') OR
(CustFieldDef_ID = 'CDCAE4277D10465F8960853976EAE6B6') OR
(CustFieldDef_ID = 'C6B0C4C8B67D4B9589B91104BE7FCF54') OR
(CustFieldDef_ID = '781DED61758C4001B24D56F971E1B4E4')))
Any help would be greatly appreciated.
Thank you and have a fantastical day