Solved

sql / asp

Posted on 2011-09-09
1
382 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
1 Comment
 
LVL 18

Accepted Solution

by:
lludden earned 500 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now