(
Select name and currency from A.
Joint ownership
Select name and currency from B.
/* Combine two tables as temporary tables */
)
Group by name