How to display everything except the first row of the table?

Is it possible to display everything except the first row from a table in SQL Server 2005? I have this data:

---------------------------------
|  ID  |    Name                |
---------------------------------
|  1   |    John Smith          |
|  2   |    John Doe            |
|  3   |    John Thatcher       |
---------------------------------

In my request, I need to get "John Doe" and "John Thatcher." I don't need the โ€œIDโ€ column to display, so I cannot use ROW_NUMBER here, as shown below:

select Name from Customers where ROW_NUMBER() over (order by Id)>1

Please advice.

Thanks.

UPDATE: Clarification: I would like my query to return only a column of names, but I cannot use table expressions because I use this query as part of string concatenation:

select stuff((select ', '+pfn.FullName from PlaintiffsFullNameView pfn where pfn.SuitId=s.Id for xml path('')),1,1,'') as "CoPlaintiffs"

Now I need to convert this request to return everything except the first plaintiff in a concatenated form.

2: , : . ( ) , . "" , . ( ), , .

+3
6
SELECT  Name
FROM    (
        SELECT  Name, ROW_NUMBER() OVER (ORDER BY id) AS rn
        FROM    Customers
        ) q
WHERE   rn > 1
ORDER BY
        id

Update:

:

SELECT  Suit.*,
        FirstPlantiff.*,
        (
        SELECT  cp.Name AS [text()]
        FROM    Plantiff cp
        WHERE   cp.id <> FirstPlantiff.id
                AND cp.SuitID = Suid.ID
        ORDER BY
                cp.id
        FOR XML PATH('')
        ) AS Coplantiffs
FROM    Suit
CROSS APPLY
        (
        SELECT  TOP 1 *
        FROM    Plantiff p
        WHERE   p.SuitID = Suit.ID
        ORDER BY
                p.id
        ) FirstPlantiff
+13
SELECT Name 
FROM Customers 
WHERE  ID <> (SELECT TOP 1 ID 
              FROM Customers 
              ORDER BY ID)

, Id , , ID < > 1

+8

ROW_NUMBER , ROW_NUMBER WHERE. :

select stuff((
    select ',' + FullName
    from (
        select pfn.FullName, row_number() over (order by pfn.id) as rn
        from @suits s
        inner join @plaintiffs pfn on s.id = pfn.SuitId
    ) sub
    where rn <> 1
    for xml path('')
), 1, 1, '') subsub

:

select stuff((
    select ',' + pfn.FullName
    from @suits s
    inner join @plaintiffs pfn on s.id = pfn.SuitId
    where s.id = 1
    and pfn.id not in (
        select min(id) from @plaintiffs where SuitId = s.id)
    for xml path('')
), 1, 1, '') sub

:

declare @suits table (id int identity, CaseName varchar(max))
insert into @suits (CaseName) values ('The People v.s. Donald Duck')
declare @plaintiffs table (id int identity, 
    SuitId int, FullName varchar(max))
insert into @plaintiffs (SuitId,Fullname) 
select 1, 'John Smith'
union all select 1, 'John Doe'
union all select 1, 'John Thatcher'
+3

, Id WHERE.

, .

+1

1:

select name 
from @tbl
where id <> 1

2:

select top(select count(name) -1 from @tbl) name 
from @tbl 
order by id desc
0
SELECT * FROM Customers
EXCEPT SELECT TOP 1 * FROM Customers
0

Source: https://habr.com/ru/post/1721989/


All Articles