Hello,
I have a table called tblNameHistory. When one of our companies changes it's legal name, the old name is stored in this table, along with a date that it was changed and its Customer ID (COID). The unique identifier is LegalID. I'm having trouble pulling just the minimum date (by COID) and its former name. For example:
I want it to pull out 99999 (Nine Co.) and just the 12345 that is ZYX Company (as it has the earlier [Change Date]). Is there a way to do this and pull the former name? With my query, it's pulling each separate LegalID, not distinct COIDs. Here is my SQL statement:
Thanks!
I have a table called tblNameHistory. When one of our companies changes it's legal name, the old name is stored in this table, along with a date that it was changed and its Customer ID (COID). The unique identifier is LegalID. I'm having trouble pulling just the minimum date (by COID) and its former name. For example:
Code:
LegalID COID Former Name Change Date
1 12345 ZYX Co. 1/1/2001
2 99999 Nine Co. 5/1/2001
3 12345 ABC Co. 6/1/2010
Code:
SELECT DISTINCT tblNameHistory.COID, Min(tblNameHistory.ChangeDate) AS [Min Change Date], tblNameHistory.FormerName
FROM tblNameHistory
GROUP BY tblNameHistory.COID, tblNameHistory.FormerName
HAVING (((tblNameHistory.COID) Is Not Null) AND ((Min(tblNameHistory.ChangeDate)) Is Not Null));
Thanks!