in reply to Counting events and getting top 5 matches
The only code you show is SQL, so I'm giving you an SQL answer:
select code, username, userid, count(*) as code_count group by code, username, userid order by code, code_count
To get the "top five" out of that select statement, you can use the RANK() function:
select code, username, userid, count(*) as code_count, rank() over (ORDER BY code_count DESC) as code_rank where code_rank <= 5 group by code, username, userid
The rank() function doesn't seem to be supported on Sybase ASE. Maybe you can create the select as a view and then use some rowid trickery to get at the top five users per code group.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Counting events and getting top 5 matches
by psini (Deacon) on Sep 17, 2008 at 09:11 UTC | |
by jonadab (Parson) on Sep 17, 2008 at 11:37 UTC | |
by BrowserUk (Patriarch) on Sep 17, 2008 at 15:14 UTC | |
by psini (Deacon) on Sep 17, 2008 at 12:48 UTC | |
|
Re^2: Counting events and getting top 5 matches
by moritz (Cardinal) on Sep 17, 2008 at 09:11 UTC | |
by Corion (Patriarch) on Sep 17, 2008 at 09:18 UTC | |
by psini (Deacon) on Sep 17, 2008 at 09:22 UTC | |
|
Re^2: Counting events and getting top 5 matches
by iphony (Acolyte) on Sep 17, 2008 at 08:51 UTC |