/**
 *
 */
package com.foc.task;

/**
 * 
 * @team BBDTEK IT Team
 * @author renmb
 * @version 1.0
 * @time  2017年9月13日
 */
public class TestMain {

    /**
     * 
     * @author renmb
     * @time  2017年9月13日
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        int count = 6;
        int pageNo=2;
        int pageSize=4;
        System.out.println(count/pageSize+1);
        int startSize=(pageNo-1)*pageSize;  
        int endSize=pageNo*pageSize;
        
        String sql = "SELECT ROWNUM AS rowno,tmp.* FROM (SELECT T.PK_JKBX,T.DJZT  FROM ER_BXZB T ORDER BY T.TS DESC) tmp WHERE ROWNUM<="+endSize;
        System.out.println("SELECT * FROM ("+sql+") tm WHERE tm.rowno >"+startSize);
        
        
        int index1 = sql.indexOf("SELECT")+6;
        String prefixSql1 = sql.substring(0, index1);
        String endSql1 = sql.substring(index1);
        String qsql1 = prefixSql1+" ROWNUM AS rowno,"+endSql1;
        
        int index = qsql1.lastIndexOf("WHERE")+5;
        String prefixSql = qsql1.substring(0, index);
        String endSql = qsql1.substring(index);
        
        String qsql = prefixSql+" ROWNUM<="+endSize+" AND "+endSql;
        
        System.out.println("SELECT * FROM ("+qsql+") tmp WHERE tmp.rowno >"+startSize);
    }

}
