Hi
I am trying to get this datas, but I obtain duplicate results in ORDERS and TOTAL_PAID. Can anyone help me please? I get:
SELECT count(o.id_order) as ORDERS, sum(o.total_paid) as TOTAL_PAID, max(o.date_add) as LAST_ORDER,
c.firstname as NOMBRE, c.lastname as APELLIDOS, c.email, a.address1, a.phone, a.phone_mobile, a.postcode, s.name as STATE
FROM ps_state s, ps_customer c
JOIN ps_orders o on o.id_customer = c.id_customer
JOIN ps_address a on a.id_customer = c.id_customer
WHERE s.id_state = a.id_state
GROUP BY o.id_customer having count(o.id_order)>0
order by 1 desc
Best regards