Solved

sql / asp

Posted on 2011-09-09
1
373 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

746 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

13 Experts available now in Live!

Get 1:1 Help Now