Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table large_table as
- select column1, column2, column3, column4, column5, column6
- from
- (
- select
- a.column1, a.column2, a.start_time,
- rank() OVER(
- PARTITION BY a.column2, a.column1 order by a.start_time DESC
- ) as rank,
- last_value( a.column3) OVER (
- PARTITION BY a.column2, a.column1 order by a.start_time ASC
- RANGE BETWEEN unbounded preceding and unbounded following
- ) as column3,
- a.column4, a.column5, a.column6
- from
- (table2 s
- INNER JOIN table3 t
- ON s.column2=t.column2 and s.event_time > t.start_time
- ) a
- ) b
- where rank =1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement