?
Solved

Ms sql problem with row_number query

Posted on 2010-09-02
2
Medium Priority
?
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 32

Accepted Solution

by:
Brendt Hess earned 2000 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

762 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