date在where之后,先连表,再筛选,数据此时很多b.date为NULL的数据就被过滤掉了,因此会导致并不是预期的左表的大小
select
count(*)
from
dm_data_gr.item_spu as a
LEFT JOIN dm_data_gr.item_spu_top_sales as b on a.source_spu_id = b.source_spu_id
where
a.date = ${date}
and b.date = ${date}
select
count(*)
from
dm_data_gr.item_spu as a
LEFT JOIN dm_data_gr.item_spu_top_sales as b on a.source_spu_id = b.source_spu_id and b.date=${date}
where
a.date = ${date}
select
count(*)
from
(
select
*
from
dm_data_gr.item_spu
where
date = ${date}
) as a
left join (
select
*
from
dm_data_gr.item_spu_top_sales
where
date = ${date}
) as b ON a.source_spu_id = b.source_spu_id