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
相关产品推荐
相关产品推荐

