Count of query lines

Gkirkup

Registered User.
Local time
Yesterday, 21:20
Joined
Mar 6, 2007
Messages
628
In a query, how do I do a count of the number of lines that appear in the query? Not the number of records, because the query itself is grouped. The results are in order, highest to lowest, and I want to see just the top 50.
 
if you want the top 50 records in a query use the TOP predicate:

SELECT TOP 50
FirstName, LastName
FROM Students
WHERE GraduationYear = 1994
ORDER BY GradePointAverage DESC;

the above query will display students with the top 50 grades.

Dave
 
Dave:
That's great, thank you. Now how do I number the lines so that the numbers 1-50 show up alongside each line of the query?
 
here is an example or sequential numbering in a query
SELECT TOP 100 (select top 100 count(b.authors_name) as c
from MyTable2 b
where b.authors_name<=a.authors_name
) AS rowN, a.*
FROM MyTable2 AS a
ORDER BY a.authors_name;
 

Users who are viewing this thread

Back
Top Bottom