[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Ms sql problem with row_number query

Posted on 2010-09-02
2
Medium Priority
?
277 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard 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.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

650 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