SELECT
  CS.ClientID,
  CS.FinNumber,
  CS.GroupName
FROM
  taClients AS CS
    INNER JOIN taClientSummary AS SM ON (SM.ClientID = CS.ClientID)
WHERE
  (SM.ClientContactsJson LIKE CONCAT('%', RIGHT(@aCaller, 9), '"%'))

UNION

SELECT
  PH.ClientID,
  C1.FinNumber,
  C1.GroupName
FROM
  taPhoneCall AS PH
    INNER JOIN taClients AS C1 ON (C1.ClientID = PH.ClientID)
WHERE
  (PH.ClientID IS NOT NULL) AND
  (RIGHT(PH.InovoCaller, 9) = RIGHT(@aCaller, 9))

ORDER BY
  3
