?
Solved

sql / asp

Posted on 2011-09-09
1
Medium Priority
?
416 Views
Last Modified: 2012-05-12
I have the following SQL query. Query 1 is working fine.
and I tried to modify to get particular rownumber like query 2.
it alerts me error in sql server.

Can experts help me to fix query 2 and tell me what's wrong?
I used this query for website, like asp

Thanks


Query 1:
Select PartNo,
            Row_Number() Over(Order By PartNo) rownumber,
           Count(*) Over() as TotalRecordCount
From Products
where Category = 'COOLANT'
Order By partno asc

Query 2:
Select PartNo,
            Row_Number() Over(Order By PartNo) as  rownumber,
           Count(*) Over() as TotalRecordCount
From Products
where Category = 'COOLANT' and rownumber = 1
Order By partno asc
0
Comment
Question by:Webboy2008
[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
1 Comment
 
LVL 18

Accepted Solution

by:
lludden earned 2000 total points
ID: 36512327
SELECT * FROM (
Select PartNo,
            Row_Number() Over(Order By PartNo) as  rownumber,
           Count(*) Over() as TotalRecordCount
From Products
where Category = 'COOLANT' ) T1
WHERE rownumber = 1
Order By partno asc
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

800 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