Building distinct Column from a common column from two tables
The following code should get you the result for MS SQL or MySQL:

select distinct f.Account_code__C,
case when a.Account_code__C&lt;&gt;'' then 'Y' else 'N' end AS DQ_TOBE, 
case when b.Account_code__C&lt;&gt;'' then 'Y' else 'N' end AS DQ_CURRENT
from (
    SELECT Account_code__C FROM GODS.DQ_TOBE
    union
    SELECT Account_code__C FROM GODS.DQ_CURRENT
) f
left join GODS.DQ_TOBE a on a.Account_code__C=f.Account_code__C
left join GODS.DQ_CURRENT b on b.Account_code__C=f.Account_code__C