隨筆-16  評論-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 閱讀(545) 評論(0)  編輯  收藏 所屬分類: DataBase
          主站蜘蛛池模板: 穆棱市| 永登县| 株洲市| 喀喇| 开封市| 三穗县| 怀来县| 肇东市| 鄂伦春自治旗| 观塘区| 镇安县| 高青县| 新郑市| 盘山县| 萝北县| 闵行区| 永清县| 新泰市| 佛坪县| 芦溪县| 达州市| 高州市| 青田县| 尼勒克县| 大悟县| 抚松县| 威海市| 九龙县| 宜阳县| 永济市| 威信县| 梨树县| 松江区| 承德县| 新乐市| 科技| 中宁县| 吉隆县| 开平市| 大宁县| 瑞丽市|