code: public String getSmartCountSql(String sql, String name) {
          //解析SQL
          Statement stmt = null;
          //特殊sql不需要去掉order by时，使用注释前缀
          if(sql.indexOf(KEEP_ORDERBY) >= 0){
              return getSimpleCountSql(sql);
          }
          try {
              stmt = CCJSqlParserUtil.parse(sql);
          } catch (Throwable e) {
              //无法解析的用一般方法返回count语句
              return getSimpleCountSql(sql);
          }
          Select select = (Select) stmt;
          SelectBody selectBody = select.getSelectBody();
          try {
              //处理body-去order by
              processSelectBody(selectBody);
          } catch (Exception e) {
              //当 sql 包含 group by 时，不去除 order by
              return getSimpleCountSql(sql);
          }
          //处理with-去order by
          processWithItemsList(select.getWithItemsList());
          //处理为count查询
          sqlToCount(select, name);
          String result = select.toString();
          return result;
      }
docs: 获取智能的countSql
  
  @param sql
  @param name 列名，默认 0
  @return