I am working with an Oracle 10g Database.
I have the following two tables:
T_DEBTOR : - ID_DEBTOR - HEADER T_ELEMENT : -
You could use the SQL Case statement, to distinguish when HEADER is null and when it has a value: http://www.tizag.com/sqlTutorial/sqlcase.php