select 
b.Waccountid EXTID ,
a.SACCOUNTCODE,
a.SDESCRIPTION, 
a.BOPENITEM,
a.BINACTIVE,
c.sdescription SREPORTINGGROUP1,
c.sdescription SREPORTINGGROUP2,
e.sdescription SSALESMAN,
f.COUNTRIES_NAME SPostCountry ,
g.COUNTRIES_NAME SDELCountry ,
b.SPostal1,
b.SPostal2,
b.SPostal3,
b.SPostalCode,
b.sDelivery1,
b.sDelivery2,
b.sDelivery3,
b.sDeliveryCode,
b.STelephone1,
b.STelephone2,
b.SEMail,
b.SFax,
b.FCREDITLimit,
b.FChargeAmount,
b.FDiscount,
b.FInterest,
b.SMessage,
b.WDefaultPriceTypeID,
b.DLastActivity,
b.WDUEDAYS,
 
b.Sreference,
b.SCOMPANYREGNO,
b.SFREEFIELD1,
b.SFREEFIELD2,
b.SFREEFIELD3,
b.SBANKNAME,
b.SBRANCHCODE,
b.SBANKACCOUNTNUMBER,
b.SBANKACCOUNTNAME,
b.SCREDITCARDNUMBER,
b.SCREDITCARDTYPE,
b.SCREDITCARDHOLDER
 from account a join debtor b on (a.waccountid=b.WaccountId) 
left join groups c on (a.WREPORTINGGROUP1ID = c.WGroupID)
left join groups d on (a.WREPORTINGGROUP2ID = d.WGroupID)
left join groups e on(b.WSalesmanID = e.WGroupID)
left join countries f on(b.WPostCountries_id = f.Countries_id)
left join countries g on(b.WDElCountries_id = g.Countries_id) 
where a.WAccountTypeId = 1 and a.DSYSDATE > cast('<@UPLFROMDATEDEBT@>' as timestamp)