隨筆-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 閱讀(555) 評論(0)  編輯  收藏 所屬分類: DataBase
          主站蜘蛛池模板: 连南| 福鼎市| 安仁县| 南涧| 柞水县| 靖西县| 惠安县| 瓦房店市| 台前县| 清流县| 随州市| 岚皋县| 吉木乃县| 竹山县| 岳阳市| 醴陵市| 武胜县| 巴塘县| 施秉县| 雷州市| 南雄市| 嘉兴市| 满洲里市| 新巴尔虎右旗| 峨眉山市| 宜都市| 奈曼旗| 西贡区| 新宁县| 长子县| 仁布县| 涟水县| 富源县| 建瓯市| 措美县| 台北县| 兴化市| 德州市| 延川县| 千阳县| 东乌|