Jump to content

Useful Database Queries.


Guest Nicholas

Recommended Posts

Guest Nicholas

I'd like to be able to query the customer database (using phpmyadmin) to find customers who have spent over x amount and a separate query to find customers who have ordered more than once.

Can any one help?

Cheers

Link to comment
Share on other sites

Guest Nicholas

Mysty,

Thank you, I'd spotted that, but as I said above I want to do it through phpmyadmin.

I want to do it so I can select the best customers, export to csv and make a mailing lists dependent on the criteria mentioned above.

Burgensteen,

Thanks I'll take a look, but I don't really want to be adding mods atm as we'll soon be going on to CC4, If i had the SQL I could adapt it for both (if it needed to be adapted.

Cheers

Link to comment
Share on other sites

Guest Nicholas

Okay, I've worked some out.

Find customers that have ordered above X amount or orders.

SELECT  * 

FROM  cubecart_customer 

WHERE  noOrders  >  'X'






Customers who's order was over X amount.


SELECT  * 

FROM cubecart_order_sum

LEFT  JOIN cubecart_customer ON cubecart_order_sum.customer_id = 

cubecart_customer.customer_id

WHERE prod_total >'X'






Customers who's order was over X amount and paid.


SELECT  * 

FROM cubecart_order_sum

LEFT  JOIN cubecart_customer ON cubecart_order_sum.customer_id = 

cubecart_customer.customer_id

WHERE prod_total > X AND 

STATUS  =3






Find the average order value


SELECT status, avg(prod_total)

FROM cubecart_order_sun group by status

If you can think of any more please add them to this thread.

Cheers,

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...