Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2016
    Location
    Marietta GA
    Posts
    72
    Plugin Contributions
    0

    Default SQL to Query customer's Sales History

    Hello, I'd like to write a simple mySQL query to retrieve customer sales data. I'll save to .CSV and download. Analyze in pivot table in excel.

    So the customer info is pretty simple:

    SELECT customers_id,customers_firstname, customers_lastname, customers_email_address FROM customers
    WHERE <some conditions>

    But then how to connect that with I *THINK* same customers_id in orders.order_total. It that where all order history is?

    I just plan to paste the sql into phpMyAdmin, and run it, nothing to having to do with Admin web rendering.

    Any help with the sql would be appreciated.

  2. #2
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,691
    Plugin Contributions
    9

    Default Re: SQL to Query customer's Sales History

    Code:
    SELECT c.customers_id,customers_firstname, customers_lastname, 
    customers_email_address, b.* 
    FROM customers c
    join (SELECT `customers_id`, sum(order_total)
    FROM `orders`
    group by customers_id
    ) b on c.customers_id = b.customers_id
    where
    ...
    hope that helps.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  3. #3
    Join Date
    Mar 2016
    Location
    Marietta GA
    Posts
    72
    Plugin Contributions
    0

    Default SOLVED: Re: SQL to Query customer's Sales History

    Thanks very much carlwhat -- exactly what I was looking for. And with that I was able to tweak it a bit to get a significant list of people registered on the site, and subscribed to our email, who have never completed a purchase -- perfect candidates for a special marketing offer. Thanks for helping us build the business!

    Greg

  4. #4
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,691
    Plugin Contributions
    9

    Default Re: SOLVED: Re: SQL to Query customer's Sales History

    Quote Originally Posted by greg_beyer View Post
    Thanks very much carlwhat -- exactly what I was looking for. And with that I was able to tweak it a bit to get a significant list of people registered on the site, and subscribed to our email, who have never completed a purchase -- perfect candidates for a special marketing offer. Thanks for helping us build the business!

    Greg
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

 

 

Similar Threads

  1. Replies: 9
    Last Post: 12 Jul 2023, 12:26 AM
  2. v154 Help with a SQL Query for Query Builder
    By lindasdd in forum Managing Customers and Orders
    Replies: 2
    Last Post: 24 Mar 2016, 01:18 PM
  3. v151 SQL query setup. How do I TEST a query 'off-line'?
    By lewisasding in forum General Questions
    Replies: 3
    Last Post: 8 Mar 2013, 12:24 AM
  4. Replies: 2
    Last Post: 15 Aug 2011, 04:58 AM
  5. SQL Query for extracting Order & Customer Details?
    By Rony in forum Managing Customers and Orders
    Replies: 7
    Last Post: 23 Sep 2010, 10:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR