Link to home
Start Free TrialLog in
Avatar of vliwill
vliwill

asked on

Count the TOP n Records


Is there any way of doing a count using count(*) over that only counts the first x number of records?

Reason I ask is that a search may return 300,000 results but in reality I want to say if more than 500 returned just tell the user that. SQL is so slow at counting that I don't want it ot count the full 300,000.
Avatar of Mistralol
Mistralol


What like

SELECT TOP 501 COUNT(*) FROM Table WHERE .....

If you have > 501 you say > 500 results?
ASKER CERTIFIED SOLUTION
Avatar of Rajkumar Gs
Rajkumar Gs
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vliwill

ASKER

Perfect thanks
Glad to help and for the points
Raj