select distinct c.customerid,c.firstname,c.lastname,c.email,c.Address1,c.address2,c.City,c.state,c.country,
c.zip,c.homephone,c.workphone,o.orderdate,o.status,convert(varchar,o.taxtotal) as taxtotal,o.shipmethod,
o.orderid,convert(varchar,o.shippingtotal) as shippingtotal,convert(varchar,o.handlingcharge) as handlingcharge,
convert(varchar,o.discount) as discount, ph.billingaddress,ph.billingzip,ph.acctno,ph.exproute,convert(varchar,ph.amount) as amount,
ph.payhistid,ph.authcode,ph.notes,ph.status as paystatus,ph.billingname,ph.billingcity,ph.billingstate,ph.billingcountry
from smith_storeorders o
left outer join smith_customer c on
o.customerid = c.customerid
left outer join smith_payhist ph on
o.payhistid = ph.payhistid
where o.status = 'Open' and o.portalid = @PortalId
order by c.customerid desc
---
Please help me understand...
Thank you,
Jones