在我的WHERE条件下,以下内容 w.physical_country = y.destination_country_code
工作正常,除非有英国国家。这是因为在w.physical_country列中,值是“ UK”,而在y.destination_country_code中,值是“ GB”
因此,where条件将在不匹配时跳过此条件,无论他们实际上匹配了谁,都应将其添加到表中。您将如何添加条件以考虑到这一点?
dest_leg AS(
SELECT y.*
FROM
(
SELECT
y.shipment_id,
y.route_id,
min(leg_sequence_id) max_leg_sequence_id
FROM
posimorders.sc_execution_eu.o_detailed_routes_v2 y
LEFT JOIN warehouse_attributes w -- Joining to add country of dest SC
ON w.warehouse_id = y.leg_warehouse_id
where 1=1
and w.physical_country = y.destination_country_code
group by
1,2
) x
INNER JOIN posimorders.sc_execution_eu.o_detailed_routes_v2 y
on x.route_id = y.route_id and x.shipment_id = y.shipment_id and y.leg_sequence_id = x.max_leg_sequence_id
),
答案 0 :(得分:1)
要解决英国与英国之间的冲突,可以使用:
auto