Solved

Ms sql problem with row_number query

Posted on 2010-09-02
2
242 Views
Last Modified: 2012-05-10
I have this query:

SELECT req_n,ROW_NUMBER() OVER (ORDER BY req_n) AS ROWID from req

Works fine...

How ever if I try ti limit to a specific row:

SELECT req_n,ROW_NUMBER() OVER (ORDER BY req_n) AS ROWID from req where rowid=5

I get a messahe rowid is an invalida column.

How can I do this?
0
Comment
Question by:robrodp
2 Comments
 
LVL 32

Accepted Solution

by:
bhess1 earned 500 total points
ID: 33589423
Quick and dirty - cheat:

SELECT req_n, RowID
FROM (
    SELECT req_n,ROW_NUMBER() OVER (ORDER BY req_n) AS ROWID from req
    ) Src
WHERE RowID = 5
0
 
LVL 16

Expert Comment

by:vdr1620
ID: 33589849
you can also try this below SQL

SELECT req_n,ROW_NUMBER() OVER (ORDER BY req_n) AS ROWID from req
where
ROW_NUMBER() OVER (ORDER BY req_n) =5
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question