code_junkie

Oracle Analytics - partitions and ordering of sql queries

Nov 12th, 2011
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. ROW_PRIORITY COL1 COL2 COL3
  2. 0 0.1 100 <NULL>
  3. 12 <NULL> <NULL> 3
  4. 24 0.2 <NULL> <NULL>
  5.  
  6. select 'B' METRIC, ROW_PRIORITY,
  7. last_value(col1 ignore nulls) over (ORDER BY ROW_PRIORITY) col1,
  8. last_value(col2 ignore nulls) over (ORDER BY ROW_PRIORITY) col2,
  9. last_value(col3 ignore nulls) over (ORDER BY ROW_PRIORITY) col3
  10. from (SELECT * FROM ZTEST);
  11.  
  12. METRIC ROW_PRIORITY COL1 COL2 COL3
  13. B 0 0.1 100 <NULL>
  14. B 12 0.1 100 3
  15. B 24 0.2 100 3
  16.  
  17. METRIC ROW_PRIORITY COL1 COL2 COL3
  18. B 0 0.2 100 3
  19. B 12 0.2 100 3
  20. B 24 0.2 100 3
Add Comment
Please, Sign In to add comment