Advertisement
pmkhlv

Untitled

May 26th, 2022
546
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. update analysis.orders_v
  2. set status = 0;
  3.  
  4. update analysis.orders_v
  5. set status = query1.status
  6. from (select
  7.         orderstatuslog_v.order_id,
  8.         last_value(orderstatuslog_v.status_id) over (partition by orderstatuslog_v.order_id
  9.                                  order by orderstatuslog_v.dttm asc
  10.                                  rows between unbounded preceding and unbounded following) as status
  11.       from
  12.         analysis.orderstatuslog_v) as query1
  13. where query1.order_id = analysis.orders_v.order_id;
Advertisement
RAW Paste Data Copied
Advertisement