You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SQL与Google Sheets同数据集计算结果不一致问题求助

SQL与Google Sheets计算结果不一致问题

场景1:2003年各区域摩托车销售额统计

需求:统计2003年各区域(Territory)的摩托车(Productline = 'Motorcycles')销售额

SQL查询语句

SELECT 
year_country.year_id year,
year_country.territory territory,
year_country.productline product,
sum(sales_size.sales) total_sales

FROM sales_size
JOIN year_country
ON sales_size.ordernumber = year_country.ordernumber
WHERE year_country.productline = "Motorcycles" AND year_id = "2003"
GROUP by year_country.territory
; 

Google Sheets计算方式

合并两表后使用SUMIFS公式:=sumifs([range],[range],"Motorcycles",[range],"NA",[range],"2003")
得到结果:APAC=12058.72、EMEA=50956.2、NA=65887.91,与SQL查询结果不符。

场景2:按年份统计订单平均销售额

需求:按年份统计订单平均销售额(SALES)

SQL查询语句

SELECT 
year_country.year_id year,
round(avg(sales_size.sales)) average_sales

FROM sales_size
JOIN year_country
ON sales_size.ordernumber = year_country.ordernumber
GROUP by year_id
;

Google Sheets计算方式

使用AVERAGEIF公式:=AVERAGEIF([range],[year],[range])
得到结果:2003=5454、2004=5298、2005=4958,与SQL查询结果不符。

内容的提问来源于stack exchange,提问作者Vel Green

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 09:01:01