DB/Oracle

페이지, 페이징을 주기 위한 쿼리문 예제

벨포트조던 2015. 12. 29.
반응형

 SELECT
        row_Number,
        letterNo,
        letterTitle,
        letterWrittenDate
                     
    from
        (select
            A.*,
            row_Number() over(order by letterWrittenDate asc) as row_Number, floor((rownum-1)/10) as page,
            count(*) over() as totalRecord                    
        from
            (select
                distinct x.letterNo,
                x.letterTitle,
                x.letterWrittenDate,
                x.boardNo,
                x.display,
                x.topdisplay                     
            from
                g_letter x,
                g_letterTables y                                             
            where
                x.letterNo = y.letterNo(+)                  
            order by
                x.letterNo desc                                          ) A                                        )                                    
        where
            page =  0 /**P*/                                  
        order by
            row_Number desc      ;

 

빨간줄이 포인트 ~~~ . 총 게시물수도 나타냄. 마지막에 where 절로 페이지 뷰를 선택할수 있음

반응형

댓글