select 1, a.SACCOUNTCODE, lower(Contacts.gender) gender,
d.SPOSTAL1, 
d.SPOSTAL2, 
d.SPOSTAL3, 
d.SPOSTALCODE,
d.SDELIVERY1,
d.SDELIVERY2, 
d.SDELIVERY3, 
d.SDELIVERYCODE,
d.SEMAIL,
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@>

