Skip to content

Commit

Permalink
Update orders_view.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillZhul committed May 28, 2023
1 parent 6d065a6 commit 7daf181
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions orders_view.sql
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
create or replace view analysis.orders as
select
o.order_id,
o.order_ts,
o.user_id,
o.bonus_payment,
o.payment,
o.cost,
select o.order_id,
osl.dttm as "order_ts",
o.user_id,
o.bonus_payment,
o.payment,
o."cost",
o.bonus_grant,
osl.status_id "status"
from
production.orders o
inner join
production.orderstatuslog osl
on 1 = 1
and o.order_id = osl.order_id
and o.order_ts = osl.dttm
where osl.dttm >= '2022-01-01';
osl.status_id as "status"
from production.orders o
left join production.orderstatuslog osl
on osl.order_id = o.order_id
and osl.dttm = (select max(osl2.dttm)
from production.orderstatuslog osl2
where osl2.order_id = o.order_id);

0 comments on commit 7daf181

Please sign in to comment.