Solved

Magento 1.9.2 SQL Query to retrive buyers from our customers

Posted on 2016-08-03
6
142 Views
Last Modified: 2016-08-08
We need to retrive form our database all the buyers form our customers during a range of dates.

That is all the customers that bought something duting a range of dates, we are using Magento 1.9.2

Thank you!
0
Comment
Question by:apocalip30
  • 3
  • 2
6 Comments
 
LVL 41

Expert Comment

by:Sharath
ID: 41740742
SELECT * FROM Customers 
WHERE purchase_date BETWEEN 'start_date' AND 'end_date'

Open in new window

0
 
LVL 4

Expert Comment

by:Branislav Borojevic
ID: 41741420
SELECT `e`.*, MAX(o.created_at) AS `last_order_date` FROM `customer_entity` AS `e` LEFT JOIN `sales_flat_order` AS `o` ON o.customer_id = e.entity_id WHERE (`e`.`entity_type_id` = '1') GROUP BY `e`.`entity_id` HAVING (last_order_date < '2014-03-26') OR (last_order_date IS NOT NULL)

Open in new window


This will return all customers that made a purchase from the last_order_date (you can set your own date) and the date when you make the query.

Hope it helps.

I tested it myself, it should work and return what you need.

Let me know if it works for you.
0
 

Author Comment

by:apocalip30
ID: 41742987
Yes it worked fine, thanks !

 ¿could we include number of order per customer?
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 4

Accepted Solution

by:
Branislav Borojevic earned 500 total points
ID: 41744545
SELECT customer_email, customer_firstname, customer_lastname, SUM(subtotal_invoiced) AS total_of_orders, MIN(created_at) as first_order_date, MAX(created_at) as last_order_date, COUNT(*) as number_of_orders FROM sales_flat_order GROUP BY customer_email

Open in new window


The following code will show you Customer Email, First and Last Name, Total of Orders for that customer, when they made the first order, and when they made the last order.
0
 

Author Comment

by:apocalip30
ID: 41747002
great thanks!
0
 

Author Closing Comment

by:apocalip30
ID: 41747309
thks
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

E-commerce is quite a gambling world, and you should never entrust your business to a lucky chance. In order to outrun your competitors in a race to attract as many customers as possible, you need to have a well thought-out strategy under your belt.…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question