我正在使用cakePHP,并且我遇到了microsoft sql server的问题。基本上,我正在提取有关不同农民成功率的数据。一旦行计算每个传单的收入。'
SUM(o.TotalPrice) / COUNT(cc.CustomerID) AS RevPerFlyer
问题是,cakePHP正在计算这个值是错误的。这是我的整个查询:
SELECT
c.State,
'?' AS FlyersMailed,
COUNT(o.CampaignCustomerID) AS Orders,
SUM(o.TotalPrice) AS TotalRevenue,
SUM(o.TotalPrice) / COUNT(cc.CustomerID) AS RevPerFlyer
FROM Customer c
INNER JOIN CampaignCustomer cc
ON c.CustomerID = cc.CustomerID
LEFT JOIN CustomerOrder o
ON cc.CampaignCustomerID = o.CampaignCustomerID
WHERE 1=1
AND OrderStatusID NOT IN (4,9,10,11,13)
AND cc.CampaignID = 8
GROUP BY
State
ORDER BY
当我在sql server中直接运行时,我得到了正确的数据。 示例:这是
RevPerFlyer为州AK:73.924
然而,当我从蛋糕中运行这个完全相同的sql时,这就是我得到的结果:
RevPerFlyer为州AK:7.2502
有谁知道问题可能是什么?也许sql server有问题? 提前谢谢!