LauraPresta Posted November 29, 2016 Share Posted November 29, 2016 Hello guys, Im looking for a way to get a .csv containing customers list with the date of their last order (i think it is simple a sql request) Someone got an idea or able to do this simple module ? Link to comment Share on other sites More sharing options...
w3bsolutions Posted November 30, 2016 Share Posted November 30, 2016 This SQL query will give you that. You can then export to CSV using your DB manager. SELECT c.id_customer, c.firstname, c.lastname, orders.date_add AS last_order FROM ps_customer c LEFT JOIN ( SELECT o.id_customer, o.date_add FROM ps_orders o INNER JOIN ( SELECT id_customer, max(date_add) as mostRecent FROM ps_orders GROUP BY id_customer ) ord ON o.id_customer = ord.id_customer AND o.date_add = ord.mostRecent ) orders ON c.id_customer = orders.id_customer Customers that have not placed an order will have a null value on last_order field. 1 Link to comment Share on other sites More sharing options...
LauraPresta Posted November 30, 2016 Author Share Posted November 30, 2016 This is working nicely, thank you fire2 ! It should be usefull for a lot of people to chose customers for newsletter Link to comment Share on other sites More sharing options...
endurer Posted October 5, 2017 Share Posted October 5, 2017 This SQL query will give you that. You can then export to CSV using your DB manager. SELECT c.id_customer, c.firstname, c.lastname, orders.date_add AS last_order FROM ps_customer c LEFT JOIN ( SELECT o.id_customer, o.date_add FROM ps_orders o INNER JOIN ( SELECT id_customer, max(date_add) as mostRecent FROM ps_orders GROUP BY id_customer ) ord ON o.id_customer = ord.id_customer AND o.date_add = ord.mostRecent ) orders ON c.id_customer = orders.id_customer Customers that have not placed an order will have a null value on last_order field. Hi there, I am getting the following error in sql manager: "Undefined "checkedSelect" error" Link to comment Share on other sites More sharing options...
w3bsolutions Posted October 14, 2017 Share Posted October 14, 2017 Hi there, I am getting the following error in sql manager: "Undefined "checkedSelect" error" which version of PS? Link to comment Share on other sites More sharing options...
endurer Posted October 23, 2017 Share Posted October 23, 2017 On 15/10/2017 at 3:39 AM, w3bsolutions said: which version of PS? 1.6.1.17 Thanks Link to comment Share on other sites More sharing options...
w3bsolutions Posted October 23, 2017 Share Posted October 23, 2017 3 hours ago, endurer said: 1.6.1.17 Thanks The query runs fine on any DB manager (e.g., PhpMyAdmin), not the Prestashop backend SQL query manager. I just tried it on a PS 1.6.1.17 shop. Link to comment Share on other sites More sharing options...
endurer Posted November 28, 2017 Share Posted November 28, 2017 On 24/10/2017 at 4:41 AM, w3bsolutions said: The query runs fine on any DB manager (e.g., PhpMyAdmin), not the Prestashop backend SQL query manager. I just tried it on a PS 1.6.1.17 shop. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now