Solved

sql / asp

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

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…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.

688 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