以下查询语句,会出现聚合不完全的情况,理论上应该输出一行,但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:
查询结果2:
合理结果,应该是: