隨筆-16  評(píng)論-84  文章-1  trackbacks-0

          Here i take jobs table of pubs databse for example,details as follow: 

          select top eachpage *  from  jobs where job_id not in ( select top (eachpage*(currentpage-1))  job_id from jobs order by job_id desc)) order by job_id desc;

          explain:
          1. eachpage : the number of each page show the recorder
          2.currentpage: current page

          notice:
          the red line in the sentence,you should take care of it, because Microsoft SQLServer  TOP Function can't support the expression .it can only support a number.
          so before you prepare to buildup the sql sentence ,you should alread calculate the result of the expression about (eachpage*(currentpage-1))  .

          Example:
          set  eachpage=3
                currentpage=5
           so  (eachpage*(currentpage-1)) =12
          select top 3 * from jobs where (job_id not in (select top 12 job_id from jobs order by job_id desc)) order by job_id desc


          posted on 2008-12-03 16:00 absolute 閱讀(546) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): DataBase
          主站蜘蛛池模板: 临汾市| 五指山市| 信丰县| 龙州县| 武乡县| 呼图壁县| 正定县| 周口市| 永兴县| 哈尔滨市| 什邡市| 和平县| 泰顺县| 公主岭市| 香河县| 五寨县| 务川| 高陵县| 浠水县| 葫芦岛市| 赫章县| 东至县| 广灵县| 重庆市| 连山| 黎川县| 安康市| 抚顺市| 樟树市| 富裕县| 淅川县| 岚皋县| 昔阳县| 伊川县| 崇左市| 老河口市| 应城市| 胶南市| 闽侯县| 满城县| 怀来县|