select 1, a.SACCOUNTCODE, lower(Contacts.gender) gender,
d.SPOSTAL1, 
d.SPOSTAL2, 
d.SPOSTAL3, 
d.SPOSTALCODE,
c.COUNTRIES_NAME,
Contacts.FIRSTNAME  Name,
Contacts.LASTNAME LastName ,
a.SDESCRIPTION CompName 
   from account a join debtor  d on a.WAccountid = D.WAccountid
  left join contacts on d.WContactID = Contacts.RECORDID
  left join countries c on c.countries_id = d.WPOSTCOUNTRIES_ID
 where a.WAccountid = <@WACCOUNTID@>
  union
  select 2, a.SACCOUNTCODE,lower(Contacts.gender) gender,
d.SDELIVERY1, 
d.SDELIVERY2, 
d.SDELIVERY3, 
d.SDELIVERYCODE,
c.COUNTRIES_NAME,
Contacts.FIRSTNAME  Name,
Contacts.LASTNAME LastName ,
a.SDESCRIPTION CompName 
   from account a join debtor  d on a.WAccountid = D.WAccountid
  left join contacts on d.WContactID = Contacts.RECORDID
  left join countries c on c.countries_id = d.WDELCOUNTRIES_ID
 where a.WAccountid = <@WACCOUNTID@>
order by 1
