隨筆-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
          主站蜘蛛池模板: 招远市| 威海市| 驻马店市| 江北区| 鄂州市| 静宁县| 行唐县| 利津县| 梁平县| 山阳县| 芦山县| 云林县| 保定市| 乌恰县| 罗田县| 鹤壁市| 壶关县| 基隆市| 娄底市| 新乡县| 河东区| 玉林市| 抚顺县| 永寿县| 蒙城县| 西宁市| 石城县| 环江| 六安市| 乐业县| 湟中县| 抚远县| 新宁县| 甘孜县| 鄯善县| 大港区| 隆尧县| 买车| 新闻| 黄大仙区| 正镶白旗|