본문 바로가기
아빠방/Tech

간단한 페이징 쿼리

by 탱탱이아빠 2016. 4. 16.
SELECT COUNT(*) FROM TableName WHERE ID=61;

SELECT * FROM (
     SELECT A.*, 
                 ROWNUM AS RNUM,
                 FLOOR((ROWNUM-1)/100+1) AS PAGE,
                 COUNT(*) OVER() AS TOTCNT FROM (
          SELECT T.Field1, L.Field2, L.Field3, L.Field4
FROM TableName1 T, TableName L
WHERE 
L.ID=61 AND L.Field1!= 0
  AND L.Field1= T.Field1
ORDER BY Field2 DESC
    ) A
) WHERE PAGE = 1;


반응형

댓글