View Single Post
  #1   IP: 112.87.93.182
Old 2015-03-31, 12:32 AM
Xenia Xenia is offline
初级会员
 
Join Date: 2005-11-05
Posts: 3
Xenia 现在声名狼藉
Default Determine X-Cart Product Sales Statistics

This mysql query can be used in phpMyAdmin or as part of a PHP script to evaluate your X-Cart product database and determine the numbers of sales a product has generated along with the first and last purchase dates.

This information can be very useful for determining which products you may want to put more marketing focus on, and those which you may want to shelve altogether.

Code:
SELECT p.productid, p.product, COUNT( od.orderid ) AS sales,
FROM_UNIXTIME( MIN( o.date ) , '%Y %M %e' ) AS first_order,
FROM_UNIXTIME( MAX( o.date ) , '%Y %M %e' ) AS last_order
FROM xcart_products AS p
LEFT JOIN xcart_order_details AS od ON p.productid = od.productid
LEFT JOIN xcart_orders AS o ON o.orderid = od.orderid
WHERE p.forsale = 'Y'
GROUP BY od.productid
ORDER BY sales DESC , p.productid DESC
Reply With Quote