oracle

1:查询同一张表中,多个字段值都相同且记录数大于1
SELECT ACCOUNTNAME,memberid,cardcode,count(*)
FROM cards
GROUP BY cardcode,memberid,ACCOUNTNAME
having COUNT(*) > 1

CREATE OR REPLACE PROCEDURE P_Pagination_Util --存储过程分页工具
        (
        sqlString VARCHAR2,--查询语句
        page  int,--第几页
        perPageCount int,--每页几条记录
        totalPage out SYS_REFCURSOR,--查询出的总页数
        pageResultSet out SYS_REFCURSOR--当前页查询出来的结果集
        )
    AS
        pageSql varchar(2000);--查询某页结果的SQL语句
  BEGIN
        open totalPage for 'select count(1) total from ('||sqlString||')';--查询出总数
        pageSql := 'select * from (select rownum rn,t.* from ('||sqlString||') t where rownum<='||(page*perPageCount)||')  where rn > '||(page-1)||'*'||perPageCount;
        open pageResultSet for pageSql;
  END P_Pagination_Util;

你可能感兴趣的:(oracle)