如何在 SQL Server 2005 Express 中排除第一行

发布于 2024-11-29 02:25:49 字数 94 浏览 1 评论 0原文

我想从 SQL Server 2005 Express 数据库中排除第一行的显示...我该如何执行此操作?

我知道如何仅返回顶行,但如何返回除顶行之外的所有行

I want to exclude the first row from displaying from a SQL Server 2005 Express database... how do I do this?

I know how to return just the top row, but how do I return all rows, except the top row

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一刻暧昧 2024-12-06 02:25:49
SELECT *
FROM yourTable 
WHERE id NOT IN (
         SELECT TOP 1 id 
         FROM yourTable 
         ORDER BY yourOrderColumn)
SELECT *
FROM yourTable 
WHERE id NOT IN (
         SELECT TOP 1 id 
         FROM yourTable 
         ORDER BY yourOrderColumn)
伏妖词 2024-12-06 02:25:49
SELECT *
    FROM SomeTable
    WHERE id <> (SELECT MIN(id) FROM SomeTable)
    ORDER BY id
SELECT *
    FROM SomeTable
    WHERE id <> (SELECT MIN(id) FROM SomeTable)
    ORDER BY id
梦巷 2024-12-06 02:25:49
select * from 
    (select ROW_NUMBER() over (order by productid) as RowNum, * from products) as A
where A.RowNum > 1
select * from 
    (select ROW_NUMBER() over (order by productid) as RowNum, * from products) as A
where A.RowNum > 1
枯叶蝶 2024-12-06 02:25:49

当您说您不想要顶行时,我假设您有某种 order by 来定义哪一行位于顶部。此示例使用 ID 列来执行此操作。

declare @T table(ID int, Col1 varchar(10))

insert into @T
select 1, 'Row 1' union all
select 2, 'Row 2' union all
select 3, 'Row 3'

select ID
from @T
where ID <> (select min(ID)
             from @T)
order by ID

When you say you don't want the top row I assume you have some kind of order by that defines which row is at the top. This sample uses the ID column to do that.

declare @T table(ID int, Col1 varchar(10))

insert into @T
select 1, 'Row 1' union all
select 2, 'Row 2' union all
select 3, 'Row 3'

select ID
from @T
where ID <> (select min(ID)
             from @T)
order by ID
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文