我正在尝试从两个日期之间的表中提取数据并将其相加以得到一个数字。我的代码如下:
SELECT Total_Rode, SUM(Total_Rode)
FROM Sales
WHERE Sales.Sales_Date BETWEEN DATE_SUB(Budget.Budget_Date, INTERVAL 364 DAY)
AND DATE_SUB(Budget.Budget_Date, INTERVAL 357 DAY)
AND Sales.Company = '98'
GROUP BY Total_Rode
我一直收到错误消息"数据库错误:执行查询时遇到问题。 (操作数应包含1列)#1241
答案 0 :(得分:0)
您错过了加入Budget
表
SELECT Total_Rode, SUM(Total_Rode)
FROM Sales
join Budget
on sales.commoncolumn = Budget.commoncolumn
WHERE Sales.Sales_Date BETWEEN DATE_SUB(Budget.Budget_Date, INTERVAL 364 DAY)
AND DATE_SUB(Budget.Budget_Date, INTERVAL 357 DAY)
AND Sales.Company = '98'
GROUP BY Total_Rode