Guest User

Untitled

a guest
Dec 11th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 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, p.*, t.qty
  14. from
  15. (
  16. select count(*) as qty
  17. from table_name
  18. where ...
  19. ) t
  20. cross /* left */ join
  21. (
  22. select *
  23. from table_name p
  24. where ...
  25. -- order by ...
  26. ) p
  27. where (rownum <= 10)
Add Comment
Please, Sign In to add comment