Guest User

Untitled

a guest
Dec 11th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 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. with vtab as (
  14. select
  15. t.*,
  16. count(*) over() as cnt,
  17. from table_name t
  18. where ...
  19. )
  20. select col1, col2, col3, ..., cnt
  21. from vtab
  22. order by ...
  23. OFFSET :v_offset ROWS FETCH NEXT :v_next ROWS ONLY;
  24.  
  25. select rownum as rn, p.*, t.qty
  26. from
  27. (
  28. select count(*) as qty
  29. from table_name
  30. where ...
  31. ) t
  32. cross /* left */ join
  33. (
  34. select *
  35. from table_name p
  36. where ...
  37. -- order by ...
  38. ) p
  39. where (rownum <= 10)
Add Comment
Please, Sign In to add comment