I think you're describing this situation?
If so, you'll need to do a couple of things for your query.
The first will be to check what you are using internally in your query for the dimension key field - because you'll need to use the same value for both rows on each item. E.g. If rows numbered 1 and 2 above are also having unique values in their @SELECT:DIM:....@ column values, the rows cannot be merged, and another value that is common to both rows but still offering uniqueness across the result set (e.g. the 'ID' column in my case would work for that) would need to be used instead.
Next you'll need to GROUP your results which will probably also require putting your existing query into (another) subquery.
For example, if the following contrived/theoretical query produces the results above:
select id, link1, null as link2
from sometableA
union
select id, null, link2
from sometableB
You would need to change this to a query like:
select id, max(link1) as link1, max(link2) as link2
from
(
select id, link1, null as link2
from sometableA
union
select id, null, link2
from sometableB
) subq
group by id
(Aggregation functions like 'max' on a string tend to return the non-null value, but another function or operation can be used instead if preferred or appropriate).
Then the results in the query would collapse down to this (which I think you're aiming for based on your description):