CRecordSet myRecordSet;if(myRecordSet.IsOpen()) myRecordSet.Close; myRecordSet.Open();int order=1;//order can be assigned to 1,2,3,...., int i=0;if(!myRecordSet.IsBOF()) { myRecord.MoveNext(); i++; if(i==order) break; }myRecord.data=m_data;//read date from database
我在做分页查询时遇到过这个问题,在不添加其它数据库对象作临时变量的情况下,还没找到用纯SQL实现方法 不过Oracle中有一类统计函数可以实现,但效率很差,下面是Oracle的实现: SELECT deptno, ename, sal, comm, RANK() OVER (PARTITION BY deptno ORDER BY sal DESC, comm) as rk FROM emp;
不好意思,未写完整,现补上select deptno, ename, sal, comm from (select rank() over(order by deptno) rank1, deptno, ename, sal, comm from emp order by deptno ) ss where ss.rank1 > 10 and ss.rank1 <= 100
select top 1 * from table select top 18 * from table where id not in (select top 2 id from table)
直接使用where语句就可以了。
myRecordSet.Close;
myRecordSet.Open();int order=1;//order can be assigned to 1,2,3,....,
int i=0;if(!myRecordSet.IsBOF())
{
myRecord.MoveNext();
i++;
if(i==order) break;
}myRecord.data=m_data;//read date from database
不过Oracle中有一类统计函数可以实现,但效率很差,下面是Oracle的实现:
SELECT deptno, ename, sal, comm,
RANK() OVER (PARTITION BY deptno ORDER BY sal DESC, comm) as rk
FROM emp;
select top 18 * from table where id not in (select top 2 id
from table)