Guest User

Untitled

a guest
Dec 11th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. with vtab as (
  2. select
  3. t.*,
  4. count(*) over() as cnt,
  5. row_number() over(order by col1) as rn
  6. from table_name t
  7. where ...
  8. )
  9. select col1, col2, col3, ..., cnt
  10. from vtab
  11. where rn <= 10
  12.  
  13. select rownum as rn, t.*
  14. from
  15. (
  16. select p.*, t.qty
  17. from
  18. (
  19. select count(*) as qty
  20. from table_name
  21. where ...
  22. ) t
  23. cross join table_name p
  24. where ...
  25. ) t
  26. where (rownum <= 10)
Add Comment
Please, Sign In to add comment