it depends on your orderstatuses -
if you enumerate id order state for "successfull" order
fe
5, 12, 18
then you can write
Quoteselect count(id_order) as cntorders, max(o.date_add) as latest, c.id_customer, lastname, firstname from ps_customer c join ps_orders o on o.id_customer = c.id_customer where current_state in (5,12,18) group by o.id_customer having count(o.id_order)>1 order by 1 desc
or you can follow 'invoice' flag
select count(id_order) as cntorders, max(o.date_add) as latest, c.id_customer, lastname, firstname
from ps_customer c
join ps_orders o on o.id_customer = c.id_customer
where current_state in (select id_order_state FROM ps_order_state where invoice=1)
group by o.id_customer having count(o.id_order)>1
order by 1 desc