Win Surprise Gifts!!!
Top 5 Contributors of the Month
Post New Question
Subscribe to Forum
What is SQL to get the row number with Where clause
September 25, 2008
I am using SQL Server 2005 Express. I am trying to get the row number with a condition. I wrote a stored procedure like this
Create PROCEDURE VendorTableRowNumber
-- Add the parameters for the stored procedure here
SELECT ROW_NUMBER() OVER(ORDER BY VendorID ASC) AS RowNumber,VendorID
WHERE VendorID= @VendorID
I have 6 rows and for any value of vendorID, I get the row number as 1. But if there is no Where Clause it gives the correct corresponding row numbers for all the 6 rows. What is the correct SQL for this
Posted Date: February 08, 2009 Points: 5
Try like this
SELECT * FROM ( select Title,created_date,Disptext,UserID,Category_Id cityid,isactive ROW_NUMBER() OVER (ORDER BY created_date desc) as row FROM tableName) a WHERE row > 10 and row <= 20
To post reply
Related Questions Related Questions
how do i get the number of days between two dates
How to count number of Days present?
How to find number of days present in a month?
Random Number code
Serial Number incrementation
Need a Function to be called from a custom validator to check the number of characters in a textbox
WHY ALWAYS HAVING CLAUSE SHOULD BE USED AFTER GROUPBY
Regular expression validator for phone number
Excele sheet number format
What is a WHEN OTHERS clause in Oracle?
Latest Forum Questions From The Same Category
Help to get SQL output
how to restore my sql database from my hosting provider?
SQL query to update date range
Add allowance to employee table is wrong or true according to my case
how to remove trailing zeroes in a decimal in sql server
Required Union All Result in two different column
Sql Multiple table data retrival
Table Translation records
How select huge Data from sql without take long time?
Passing using parameter in store procedure get the top3 record from the table
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more
Quick Links For Forum Categories:
Hall of Fame
Terms of Service
Tell A Friend