Solved

Ms sql problem with row_number query

Posted on 2010-09-02
2
268 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:
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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

726 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