Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. create table large_table as
  2. select column1, column2, column3, column4, column5, column6
  3. from
  4. (
  5. select
  6. a.column1, a.column2, a.start_time,
  7. rank() OVER(
  8. PARTITION BY a.column2, a.column1 order by a.start_time DESC
  9. ) as rank,
  10. last_value( a.column3) OVER (
  11. PARTITION BY a.column2, a.column1 order by a.start_time ASC
  12. RANGE BETWEEN unbounded preceding and unbounded following
  13. ) as column3,
  14. a.column4, a.column5, a.column6
  15. from
  16. (table2 s
  17. INNER JOIN table3 t
  18. ON s.column2=t.column2 and s.event_time > t.start_time
  19. ) a
  20. ) b
  21. where rank =1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement