찾으면 안보이길래 남긴다 .

출처 : http://social.technet.microsoft.com/wiki/contents/articles/23811.paging-a-query-with-sql-server.aspx



2013/03/08 - [프로그램 자료/MS-SQL] - MSSQL 순번 출력, 그룹순번출력 row , row_number



declare @curPage int

declare @rowCount int

set @curPage = 1

set @rowCount = 10

 

 

select *

from (

        select ROW_NUMBER() OVER(ORDER BY WORD) AS ROW_NUM, WORD, CNT

        from TestTable

        where 1=1

               and YYMM = '2015-04'

               and CNT > 10

) as a

where ROW_NUM BETWEEN ((@curPage - 1) * @rowCount + 1) AND (@curPage * @rowCount)











Posted by motolies
,