I have one DB with managers and its dependent users. And the other db on other server, with some other information about users.
I want to query second DB and get data grouped by managers. One solution for this is to loop through result from db2 and calculate new result in application, but I would like to try to build result set from db1, with data about users and its managers to query to be executed on db2. Something like pseudo code below:
SELECT
b.manager_id,
SUM(a.column)
FROM user a
JOIN <resultset_with_assoc_between_user_and_manager> b ON a.user_id = b.manager_id
GROUP BY b.manager_id
Is this possible, without making any new tables in db2, just to make query with data from db1?