What you're probably looking for is relation between Orion.APM.ComponentSetting and Orion.APM.ExternalSetting. Even if there are no relations defined in schema between these entites, they can me mapped together as following: Orion.APM.ComponentSettings.Value (string) holds ID of appropriate Orion.APM.ExternalSetting record. I believe query like following could help you solve your problem.
SELECT c.ComponentID, Name, es.Setting as ComponentSetting, est.Setting as TemplateSetting
FROM Orion.APM.Component c
LEFT JOIN Orion.APM.ComponentSetting cs ON c.ComponentID=cs.ComponentID AND cs.ValueType=4
LEFT JOIN Orion.APM.ExternalSetting es ON cs.Value=ToString(es.ID)
LEFT JOIN Orion.APM.ComponentTemplateSetting cts on c.TemplateID=cts.ComponentTemplateID AND cts.ValueType=4
LEFT JOIN Orion.APM.ExternalSetting est ON cts.Value=ToString(est.ID)
WHERE cs.ValueType=4 OR cts.ValueType=4
That worked perfectly.