본문 바로가기
Developer/DB

[DB] OVER()함수

by 순수한소년 2024. 1. 18.
728x90
반응형

SELECT

   ROWNUM

, COUNT (TEST_SEQ) OVER () TOTAL_CNT
, COUNT ( TEST _SEQ) OVER () - ROWNUM + 1 display_no

FROM  TEST _STUDENT CS

AND     TOTAL_CNT + 1 - display_no > ( ('1' - 1)*'10' )
AND     ( ('1' - 1)*'10' ) + '10' >= TOTAL_CNT + 1 - display_no

 

<!-- currentPage 가 -1 일 경우 전체 검색. -->
<if test="startNum != null and numPerPage != null and currentPage != null and currentPage != -1">
<if test='( (currentPage - 1)*numPerPage ) &lt; 0 '>
AND     TOTAL_CNT + 1 - display_no > 0
AND     0 + #{numPerPage} >= TOTAL_CNT + 1 - display_no
</if>
<if test='( (currentPage - 1)*numPerPage ) &gt; -1 '>
AND     TOTAL_CNT + 1 - display_no > ( (#{currentPage} - 1)*#{numPerPage} )
AND     ( (#{currentPage} - 1)*#{numPerPage} ) + #{numPerPage} >= TOTAL_CNT + 1 - display_no
</if>
</if>

 

paginationInfo.setTotalRecordCount(testList.isEmpty() ? 0 : Integer.parseInt( testList.get(0).get("totalCnt").toString()));

반응형