Jump to content

SQL Query to retrieve customers who have not ordered yet


camfab

Recommended Posts

Hello,

 

I'm trying to retrieve via sql query the list of all customers which have not ordered yet (in order to give them a particular discount)

This is the code:

select c.id_customer, c.firstname, c.lastname, count(o.id_order) as ordercnt from ps_customer c
left join ps_orders o on c.id_customer = o.id_customer group by o.id_customer 

but this query report all customers with order count as 1 (also the customers which have not ordered yet...

Can you help me?
thank you !

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...