DB-Fiddle
CREATE TABLE operations ( id int auto_increment primary key, time_stamp DATE, product VARCHAR(255), plan_week VARCHAR(2
I would just use window functions:
select o.*, (case when min(plan_week) over (partition by product) = max(plan_week) over (partition by product) then 'no' else 'yes' end) as switched from operations o;