我最近遇到了这种必要性,并且没有关于如何直接执行此操作的明确查询或文档。
答案 0 :(得分:0)
解决方案是此SQL查询
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
这将导出客户ID,电子邮件,商店信用和奖励积分。