我需要选择两列。计算一列的总和并显示它2.显示列。所以我尝试下面的代码
SELECT Sum(CONVERT(FLOAT, Replace(total, Char(0), ''))) AS Total,
[product name]
FROM tb_sales_entry_each_product
GROUP BY [sales date]
错误消息
Column 'tb_sales_entry_each_product.Product Name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
我犯了错误。谢谢
答案 0 :(得分:1)
试试这个:
select SUM(CONVERT(float, REPLACE(Total, CHAR(0), ''))) as Total,
[Product Name] ,[Sales Date]
from tb_sales_entry_each_product
group by [Sales Date],[Product Name]
答案 1 :(得分:1)
只需要分组
select SUM(CONVERT(float, REPLACE(Total, CHAR(0), ''))) as Total, [Product Name]
from tb_sales_entry_each_product group by [Sales Date], [product name]
当您进行数字计数总和等时,需要对任何其他列进行分组。 这就是你所有的遗失