隨筆-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 閱讀(551) 評論(0)  編輯  收藏 所屬分類: DataBase
          主站蜘蛛池模板: 左权县| 东丰县| 会理县| 镇坪县| 永胜县| 息烽县| 永新县| 横山县| 贵定县| 辽阳县| 巴东县| 平定县| 大埔县| 炎陵县| 醴陵市| 万年县| 东山县| 武冈市| 宜都市| 揭西县| 武汉市| 咸丰县| 长治县| 平塘县| 清丰县| 江山市| 行唐县| 东乌| 溧阳市| 中山市| 芷江| 昌邑市| 云南省| 博乐市| 滁州市| 南岸区| 民和| 凤阳县| 伊金霍洛旗| 容城县| 泗洪县|