SQL Server: Getting string before the last occurrence '>' I have column called assocname.

Sample data:

1. FirstParty&gt;Individual:2
2. FirstParty:3&gt;FPRep:2&gt;Individual
3. Incident&gt;Vehicle:2&gt;RegisteredOwner&gt;Individual3


I want to get the string before the last occurrence '>'. Here is the result:

1. FirstParty
2. FirstParty:3&gt;FPRep:2
3. Incident&gt;Vehicle:2&gt;RegisteredOwner


How can I do that ?
SELECT LEFT(assocname, LEN(assocname) - CHARINDEX('&gt;',REVERSE(assocname)))


So we're reversing it, finding the first '&gt;', then subtracting that from the length to find how far that character is from the beginning. Then take all characters up to that point.