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

  • Home
  • SEARCH
  • 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 495317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:34:54+00:00 2026-05-13T05:34:54+00:00

Using SQL Server 2008, but could relate to other databases as well probably. If

  • 0

Using SQL Server 2008, but could relate to other databases as well probably.

If I had the following data (table t):

id text  date
1 Data1 2/1/2009
2 Data2 2/2/2009
3 Data3 2/3/2009
4 Data4 2/4/2009
5 Data5 2/5/2009

How could I find the index of a certain record?

indexOf(select id from t where id = 1) = 0

or

indexOf(select id from t where date = ‘2/4/2009’) = 3

I think it has something to do with ROW_Number() but not really sure…

  • 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. Editorial Team
    Editorial Team
    2026-05-13T05:34:55+00:00Added an answer on May 13, 2026 at 5:34 am

    Yes, ROW_NUMBER is exactly what you want to leverage along with the OVER clause. You can accomplish what you are trying to do using a sub-query or a CTE such as this:

    ;WITH Q as (
        SELECT id, text, date, ROW_NUMBER() OVER (ORDER BY date) as RowNumber 
        FROM t
    )
    SELECT * FROM Q WHERE RowNumber = 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using SQL Server 2008 r2. Did the following steps. But it does
I'm developing a web app and currently using sql server 2008 for it. But,
Using SQL Server 2008, is there a way to allow inserts to a table
I am using SQL Server 2008 management studio to execute the following SQL statements,
Using SQL Server 2008. This is a really junior question and I could really
I'm trying to delete a Maintenance Plan JOB using SQL Server 2008 but keep
I am using playframework with a legacy SQL Server 2008 database that has data
I am using SQL Server 2008. I have a table which has a datetime
I'm using SQL Server 2008 with Advanced Services on my Vista Home Premium. I'd
I'm using SQL Server 2008 Management studio viewing a 2005 server and have just

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.