Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 141511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:47:18+00:00 2026-05-11T07:47:18+00:00

I would need a suggestion or even a solution, how to get only the

  • 0

I would need a suggestion or even a solution, how to get only the second,third… row of a query result with high performance. I know there is the possibility of row_number(SQL Server 2005 or higher) but not for SQL Server 2000 🙁

My first try to get the fifth row was:
SELECT TOP 1 col
FROM (SELECT TOP 5 col
FROM table
ORDER BY col) q
ORDER BY col DESC

I try to explain my requirements: In my table there can be max. 5 rows for one person. But if only 4 rows for this person exists I would get a wrong result with my above query.

Any suggestions?

Any help will be appreciated!

Thx forward, Best Regards Andreas

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:47:18+00:00Added an answer on May 11, 2026 at 7:47 am

    This should do it…

    CREATE PROCEDURE [dbo].[sp_UpdateSkills] AS BEGIN     set nocount on      declare @UserID int     declare @Skill varchar(1)     declare @SkillCount int      declare @Skill1 varchar(1)     declare @Skill2 varchar(1)     declare @Skill3 varchar(1)     declare @Skill4 varchar(1)     declare @Skill5 varchar(1)      declare csrUser cursor for         select distinct UserID         from dbo.tblSkills1         order by 1      open csrUser      fetch next from csrUser into @UserID     while (@@fetch_status = 0)     begin         declare csrSkill cursor for             select Skill             from dbo.tblSkills1             where UserID = @UserID             order by Skill          set @SkillCount = 1         set @Skill1 = null         set @Skill2 = null         set @Skill3 = null         set @Skill4 = null         set @Skill5 = null          open csrSkill          fetch next from csrSkill into @Skill         while (@@fetch_status = 0 and @SkillCount < 6)         begin             print @UserID             print @Skill              if (@SkillCount = 1)                 set @Skill1 = @Skill             else if (@SkillCount = 2)                 set @Skill2 = @Skill             else if (@SkillCount = 3)                 set @Skill3 = @Skill             else if (@SkillCount = 4)                 set @Skill4 = @Skill             else if (@SkillCount = 5)                 set @Skill5 = @Skill              set @SkillCount = @SkillCount + 1              fetch next from csrSkill into @Skill         end          close csrSkill         deallocate csrSkill          insert into tblSkills2         (UserID, Skill1, Skill2, Skill3, Skill4, Skill5)         values         (@UserID, @Skill1, @Skill2, @Skill3, @Skill4, @Skill5)          fetch next from csrUser into @UserID     end      close csrUser     deallocate csrUser END 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Even if you are using Agile, you would need a high level architecture before
Does anyone know what would be the minimum rights I would need to grant
I would need to create a temp table for paging purposes. I would be
I would need some basic vector mathematics constructs in an application. Dot product, cross
What regex pattern would need I to pass to java.lang.String.split() to split a String
I'm working on a tool which would need to communitacte: send and recieve files
There may be situations where I would need to find an object by parameters
I've got an MS access database and I would need to create an SQL
Normally to attach a debuger to a running jvm you would need start the
I have a program in Perl I'm working on where I would need multiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.