I have a table sample that looks like :
KeyID Name ID Location
--------------------------------------------
20063 A DA 20439 AEP DA
20063 A DA 20063 APS DA
20063 A DA 20032 APS RT
20063 A RT 20032 APS RT
20063 B RT 20032 APS DA Legacy
Only select rows where Name and Location both ends with either DA or RT.
Exception: if location ends with legacy , include row regardless.
20063 A DA 20439 AEP DA
20063 A DA 20063 APS DA
20063 A RT 20032 APS RT
20063 B RT 20032 APS DA Legacy
How do I compare column of same row for this SQL?