|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, April 17, 2013 4:06 PM
Points: 129,
Visits: 141
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, November 20, 2009 6:49 PM
Points: 3,
Visits: 2
|
|
Your article begins with:
"Let's say you have a result set with 5000 records but you want to display only 100 of them and in the same time to display the count of ALL records (5000)."
So, how do you display the "5000"? I don't see that anywhere in your example. The article is a bit choppy.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, February 15, 2013 6:57 AM
Points: 2,
Visits: 25
|
|
| You should use ROW_NUMBER() instead of rank. Rank will assign the same number to the first to items in your data set. They are both 1 so they have the same rank. ROW_Number will be unique.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, April 17, 2013 4:06 PM
Points: 129,
Visits: 141
|
|
Hi Mike1024,
"how do I display 5000"? ... well in my example I display 54977 .. maybe I should have written 54977 instead of 5000. I hope you got the idea.
Hi gorr-688214,
In my example I used Rank() because the ContactId is not unique and I want to count the unique number of them. If you have no grouping clause then yes, you can use Row_number().
Enjoy!
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, April 05, 2013 12:50 PM
Points: 165,
Visits: 83
|
|
SELECT TOP 100 (select count(*) from X) AS Total_Counts, * FROM X
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, April 17, 2013 4:06 PM
Points: 129,
Visits: 141
|
|
Hi DavidP-340734,
Did you ever try your solution?
I've tested on a table with more the 3 mil records and my solution is more faster than yours.
Good luck!
|
|
|
|