一定数量的最高条款 [英] Top clause from certain number

查看:65
本文介绍了一定数量的最高条款的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道top子句用于从数据库中检索最大"行.

但是,有可能说我想要从40到50的行.

我知道oracle数据库具有变量"rownum",该变量在这种情况下很有用,这在Sql-Server 2005中也是可能的吗?
此致.

Amateurgrammer

I know that the top clause is used to retrieve a ''maximum'' of rows from the database.

however, is there a possibility to say "i want al the rows from 40 to 50.

I know that oracle database have the variable "rownum" which is usefull in such situations, is this also possible in Sql-Server 2005?

With kind regards.

The Amateurgrammer

推荐答案

尝试此

try this

Select top 10 *
From MyTable
Where PrimaryKeyField Not In
(Select top 10 PrimaryKeyField
From MyTable
Order By MySequenceField)
Order By MySequenceField


这样的事情做到
Something like this would do it
SELECT  col1,
        col2,
        col3
FROM    (
        SELECT  col1,
                col2,
                col3,
                ROW_NUMBER() OVER( ORDER BY col1,col2) as rownum
        FROM    MyTable
        ) a
WHERE   rownum BETWEEN 40 AND 50


这篇关于一定数量的最高条款的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆