


调试:



后在数据库数据对比发现以下两种情况:
1、品牌明细的数据的GroupID字段的值与渠道品牌ListID的数据的GroupID不一致导致;
select os.* from Apx_Brand_OrderSource AS os where os.CustomerId =1 and os.OrderSourceId Not in(select d.OrderSourceId from Apx_Brand_Detail as d where os.GroupId = d.GroupId GROUP BY d.OrderSourceId) group by os.Id ;

select * from Apx_Brand_Detail where OrderSourceId in(select os.OrderSourceId from Apx_Brand_OrderSource AS os where os.CustomerId =1 and os.OrderSourceId Not in(select d.OrderSourceId from Apx_Brand_Detail as d where os.GroupId = d.GroupId GROUP BY d.OrderSourceId) group by os.Id ) order by CreationTime desc

2、渠道品牌ListID的数据对应的明细压根就没有(占比很小,就几条数据);
select os.* from Apx_Brand_OrderSource AS os where os.CustomerId =1 and os.OrderSourceId Not in(select d.OrderSourceId from Apx_Brand_Detail as d GROUP BY d.OrderSourceId) order by os.Id ;

