asco5 (2/7/2013)
hi i would like to understand how to count in sql with different parameters?for example i have
Date, firstname, name, nationality , mode, origine, id
1/1/2010 teste teste1 fr in p 01
15/07/2005 toto tata lb out L 02
01/03/2012 teste teste1 fr in P 01
i would like to know how many poeple have the most entry in my database
for example here teste teste1 with Id 01 have the most entry it's 2 record
so i need to know the top 100 of poeple who have the most entry
result i need is for example
id 01 = 2 entry
id 02= 1 entry
thanks to help
select top 100 ID, count(*)
from YourTable
group by ID
Order by count(*)
I think that should be close to what you are looking for.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/