Jump to content

Edit History

EvaF

EvaF

it depends on your orderstatuses -

if you enumerate id order state for  "successfull" order

fe

5, 12, 18

then you can write

Quote

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 (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

 

EvaF

EvaF

it depends on your orderstatuses -

if you enumerate id order state for  "successfull" order

fe

5, 12, 15

then you can write

Quote


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 (5,12,15)
group by o.id_customer having count(o.id_order)>1
order by 1 desc

 

 

EvaF

EvaF

it deppends on your orderstate -

if you enumerate id order state for  "successfull" order

fe

5, 12, 15

then you can write

Quote


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 (5,12,15)
group by o.id_customer having count(o.id_order)>1
order by 1 desc

 

 

×
×
  • Create New...