【已解决】Doris SQL 查询聚合不完全,查询结果会被拆分多行,且每次查询拆分出的行数不固定

Viewed 81

以下查询语句,会出现聚合不完全的情况,理论上应该输出一行,但doris将查询结果分拆成多行:

select date_add(now(), interval 8 hour) as 更新时间
,a.sku
,a.fnsku
,a.站点
,a.asin
,b.quantity
,b.item_price
from hyy.view_rpt_daily_report_asin_site_new a -- 主表,站点+asin的销量
left join  (select b.country as 站点,a.asin  -- 订单日表
	,sum(a.quantity) as quantity 
	,avg(a.item_price) as item_price
	from hyy_mysql.r_rpt_order_sku_daily a 
	left join hyy_mysql.basic_account b on a.account = b.db_account_id 
	where purchase_date>=date_format(now() + interval 8 hour - interval 28 day,'%Y%m%d')
	group by b.country,a.asin
	having asin = 'B07RJXNF2R'
	) b on a.站点 = b.站点 and a.asin = b.asin -- 历史销售额
where a.asin = 'B07RJXNF2R';

且多次执行,返回的数据被拆分行数不一致:

查询结果1:
0007f488-e87d-4c31-afd6-b6d3c7ef8495.jpeg

查询结果2:
79ef4f26-b48c-4056-b525-2914cd1fe532.jpeg

合理结果,应该是:
e6ba938a-6767-4c21-aae4-0f1eaa3f8b05.jpeg

1 Answers

【问题状态】已处理
【问题处理】先改写SQL规避

先close,后续有问题可以继续追帖