Solved

sql / asp

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

803 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