select t1.voucherId,t1.EntryId,t1.Project,t3.Amount,t1.Expenses,t2.Dept from table1 as t1
JOIN table1 t2 on t1.voucherId = t2.voucherId
AND t1.EntryId = t2.EntryId
AND t1.Expenses IS NOT NULL AND t2.Dept IS NOT NULL
INNER JOIN Table2 t3 ON t2.voucherId=t3.VoucherId
Open in new window
see if it helps