#グローバルエリアの設定
update accept_orders set 
  global_area_id = 3 where sales_area_id in (1,3,4,15,16) and target_date >= "2014-01-01";
update accept_orders set 
  global_area_id = 4 where sales_area_id in (5,7) and target_date >= "2014-01-01";
update accept_orders set 
  global_area_id = 5 where sales_area_id in (8) and target_date >= "2014-01-01";
update accept_orders set 
  global_area_id = 6 where sales_area_id in (9) and target_date >= "2014-01-01";
update accept_orders set 
  global_area_id = 7 where sales_area_id in (10,12,14) and target_date >= "2014-01-01";

update sales set 
  global_area_id = 3 where sales_area_id in (1,3,4,15,16) and target_date >= "2014-01-01";
update sales set 
  global_area_id = 4 where sales_area_id in (5,7) and target_date >= "2014-01-01";
update sales set 
  global_area_id = 5 where sales_area_id in (8) and target_date >= "2014-01-01";
update sales set 
  global_area_id = 6 where sales_area_id in (9) and target_date >= "2014-01-01";
update sales set 
  global_area_id = 7 where sales_area_id in (10,12,14) and target_date >= "2014-01-01";

update shippings set 
  global_area_id = 3 where sales_area_id in (1,3,4,15,16) and target_date >= "2014-01-01";
update shippings set 
  global_area_id = 4 where sales_area_id in (5,7) and target_date >= "2014-01-01";
update shippings set 
  global_area_id = 5 where sales_area_id in (8) and target_date >= "2014-01-01";
update shippings set 
  global_area_id = 6 where sales_area_id in (9) and target_date >= "2014-01-01";
update shippings set 
  global_area_id = 7 where sales_area_id in (10,12,14) and target_date >= "2014-01-01";

update restorations set 
  global_area_id = 3 where sales_area_id in (1,3,4,15,16) and target_date >= "2014-01-01";
update restorations set 
  global_area_id = 4 where sales_area_id in (5,7) and target_date >= "2014-01-01";
update restorations set 
  global_area_id = 5 where sales_area_id in (8) and target_date >= "2014-01-01";
update restorations set 
  global_area_id = 6 where sales_area_id in (9) and target_date >= "2014-01-01";
update restorations set 
  global_area_id = 7 where sales_area_id in (10,12,14) and target_date >= "2014-01-01";

update samples set 
  global_area_id = 3 where sales_area_id in (1,3,4,15,16) and target_date >= "2014-01-01";
update samples set 
  global_area_id = 4 where sales_area_id in (5,7) and target_date >= "2014-01-01";
update samples set 
  global_area_id = 5 where sales_area_id in (8) and target_date >= "2014-01-01";
update samples set 
  global_area_id = 6 where sales_area_id in (9) and target_date >= "2014-01-01";
update samples set 
  global_area_id = 7 where sales_area_id in (10,12,14) and target_date >= "2014-01-01";

update adjustments set 
  global_area_id = 3 where sales_area_id in (1,3,4,15,16) and target_date >= "2014-01-01";
update adjustments set 
  global_area_id = 4 where sales_area_id in (5,7) and target_date >= "2014-01-01";
update adjustments set 
  global_area_id = 5 where sales_area_id in (8) and target_date >= "2014-01-01";
update adjustments set 
  global_area_id = 6 where sales_area_id in (9) and target_date >= "2014-01-01";
update adjustments set 
  global_area_id = 7 where sales_area_id in (10,12,14) and target_date >= "2014-01-01";

#営業エリアの設定(関越を北関東と信越に分割)
update accept_orders set 
  sales_area_id=3 where user_position_id in (18,43) and target_date >= "2014-01-01";
update accept_orders set 
  sales_area_id=4 where user_position_id in (8,57,137,144) and target_date >= "2014-01-01";
update sales set 
  sales_area_id=3 where user_position_id in (18,43) and target_date >= "2014-01-01";
update sales set 
  sales_area_id=4 where user_position_id in (8,57,137,144) and target_date >= "2014-01-01";
update shippings set 
  sales_area_id=3 where user_position_id in (18,43) and target_date >= "2014-01-01";
update shippings set 
  sales_area_id=4 where user_position_id in (8,57,137,144) and target_date >= "2014-01-01";
update restorations set 
  sales_area_id=3 where user_position_id in (18,43) and target_date >= "2014-01-01";
update restorations set 
  sales_area_id=4 where user_position_id in (8,57,137,144) and target_date >= "2014-01-01";
update samples set 
  sales_area_id=3 where user_position_id in (18,43) and target_date >= "2014-01-01";
update samples set 
  sales_area_id=4 where user_position_id in (8,57,137,144) and target_date >= "2014-01-01";
update adjustments set 
  sales_area_id=3 where user_position_id in (18,43) and target_date >= "2014-01-01";
update adjustments set 
  sales_area_id=4 where user_position_id in (8,57,137,144) and target_date >= "2014-01-01";
#マスターも関越エリアを分割
update master_app_production.warehouses set
  sales_area_id=3 where user_position_id in (18,43);
update master_app_production.warehouses set 
  sales_area_id=4 where user_position_id in (8,57,137,144);





