0

I came across this necessity lately and there is no explicit query or documentation on how to do this directly.

Mike
  • 3,017
  • 1
  • 34
  • 47

1 Answers1

0

The solution is this SQL query

SELECT c.CustomerID, c.EmailAddress, SUM(g.GiftAmountLeft) AS 'Store Credit', SUM(rph.points) AS 'Reward Points' 
FROM Customers AS c JOIN GiftCards AS g ON c.CustomerID = g.CustomerID 
JOIN Reward_Points_History AS rph ON c.CustomerID = rph.customerid 
GROUP BY c.CustomerID, c.EmailAddress ORDER BY c.CustomerID

This will export customer ID, e-mail, store credit and reward points.

Mike
  • 3,017
  • 1
  • 34
  • 47
  • How do you know the schema? BTW, I'd do LEFT JOINs - just in case a customer has no gift card, or reward points. – jarlh Apr 20 '17 at 12:12
  • @jarlh the query is set by Volusion customer support team. Editing the query is obviously up to your needs. – Mike Apr 21 '17 at 13:10