I am using the following to retrive a clients "secure" name if alias-type of 004 exists.
Problem I have is if the client has more than one alias type(001,002, 003) they all show up
What I need to do is if a client has an alias code of 004 then use that no matter how many they have
if they don't have an oo4 and have multiple say 003's then use the client name ..
WHEN at.CODE = '004'
THEN a.FName + ' ' + isnull(a.MName, '') + ' ' + + a.lname
ELSE c.FName + ' ' + ISNULL(c.MName, '') + ' ' + c.LName
END AS Tag_Data
FROM Client AS C
-- Note the order of the clausing here. It causes an
-- inner join to the rest of the tables BEFORE the
-- outer join is included.
Client_To_Alias_Collection AS AC
INNER JOIN Alias AS A
ON AC.OID_Link = A.OID
INNER JOIN Alias_Type AS AT
ON AT.OID = A.Alias_Type_Moniker
ON c.oid = ac.oid
AND A.EXPDate IS NULL WHERE c.OID = '12345'