michldav Posted January 3, 2014 Share Posted January 3, 2014 hi guys trying to figure this out for days... what i want to do: Make a query to be used with sql manager (p 1.5) I want to extra all customer info for customers who: made 1 valid purchase (= 1 order with status shipped). And the order should be within a time frame, say 6-18 months old. Anyone has an idea how to construct this query? It would be greatly appreciated. regards Michael Link to comment Share on other sites More sharing options...
vekia Posted January 3, 2014 Share Posted January 3, 2014 SELECT * FROM ps_customer c INNER JOIN ps_orders o on c.id_customer = o.id_customer INNER JOIN ps_order_history oh ON o.id_order = oh.id_order WHERE oh.id_order_state = 10 AND (o.date_add BETWEEN '2011-01-30 10:15:55' AND '2012-06-31 14:15:55') you can change between data params and of course use id_order_State related to shipped state in your shop Link to comment Share on other sites More sharing options...
michldav Posted January 3, 2014 Author Share Posted January 3, 2014 hey thanks for the fast response... i tried the query, but i get an error: ʺid_customerINNERʺ does not exists in the table: ps_orders. Also - where is the one-time-customer action handled? as i dont want to output customers who place 2 or more valid orders Thanks a lot for your time Link to comment Share on other sites More sharing options...
vekia Posted January 3, 2014 Share Posted January 3, 2014 ʺid_customerINNERʺ does not exists in the table: ps_orders. check your code, you probably forgot about space betwen id_customer and INNER JOIN Also - where is the one-time-customer action handled? as i dont want to output customers who place 2 or more valid orders oops! i forgot about that! i have to rebuild query, sorry Link to comment Share on other sites More sharing options...
michldav Posted January 4, 2014 Author Share Posted January 4, 2014 hi - okay i tried again.. getting the same issue.. with INNER join.. this is pasted directly from my shop: SELECT * FROM ps_customer c INNER JOIN ps_orders o on c.id_customer = o.id_customer INNER JOIN ps_order_history oh ON o.id_order = oh.id_order WHERE oh.id_order_state = 4 AND (o.date_add BETWEEN '2011-01-30 10:15:55' AND '2012-06-31 14:15:55') strange.. Link to comment Share on other sites More sharing options...
Daaaaad Posted April 17, 2014 Share Posted April 17, 2014 Hi Michldav, I have the same problem with INNER join... Did you find a way to fix it ? Link to comment Share on other sites More sharing options...
michldav Posted April 17, 2014 Author Share Posted April 17, 2014 hi David I'm sorry - but i had not luck in solving this Link to comment Share on other sites More sharing options...
vekia Posted April 17, 2014 Share Posted April 17, 2014 query with limitation to 1 order SELECT *, (SELECT count(*) AS nb from ps_orders po WHERE po.id_customer = o.id_customer GROUP BY po.id_customer) AS number_of_orders FROM ps_customer c INNER JOIN ps_orders o on c.id_customer = o.id_customer INNER JOIN ps_order_history oh ON o.id_order = oh.id_order WHERE oh.id_order_state = "1" AND (o.date_add BETWEEN '2011-01-30 10:15:55' AND '2014-06-31 14:15:55') AND (SELECT count(*) AS nb from ps_orders po WHERE po.id_customer = o.id_customer GROUP BY po.id_customer) = 1 change date in where clause (date BETWEEN date) 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