Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mattgee
Starting Member
6 Posts |
Posted - 2009-01-24 : 16:30:25
|
Hi All,I'm new to the forum and am hoping you can help me.I support a help desk system that has a SQL 2005 back end.I am wanting to create a script that will give me a Top 10 list of users who have logged tickets on the system.I'm guessing the script will have to analyze the full table results and return a list of the top 10 submitters.My SQL query skills are not great so any help would be brilliant.Thanks again.Matt |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2009-01-24 : 16:51:07
|
Something like this:select top 10 user_id, count(*) as ticket_countfrom YourTablegroup by user_idorder by ticket_count desc |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-25 : 04:39:12
|
quote: Originally posted by sunitabeck Something like this:select top 10 user_id, count(*) as ticket_countfrom YourTablegroup by user_idorder by ticket_count desc
just in case you need to include all records that have top 10 count values you need thisselect top 10 with ties user_id, count(*) as ticket_countfrom YourTablegroup by user_idorder by ticket_count desc |
 |
|
|
|
|