Hi,

On Jan 29, 2008 1:10 PM, Ramsey, Robert L <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm having trouble wrapping my head around this problem.  I have a list
> of events for multiple computers.  What I want to get is a summary of
> the top 3 most common errors for each computer.  So I get a result like
> this:
>
> Computername          event          numb_times
>
> Comp1                  logon          100
> Comp1                restart         90
> Comp1                Word Error      75
>
> Comp2                  logoff          88
> Comp2                Excel Error     82
> Comp2                Word Error      17
>
> Comp3                  logon          110
> Comp3                restart         50
> Comp3                Notepad Error   25
>
> Comp4                  logon           90
> Comp4                explorer error  89
> Comp4                print job       65
>
> Each computer might have a hundred different types of errors and a
> thousand entries in the table.
>
> I thought the sql would be something like:
>
> Select computername, event, count(event) and numb_times, from eventtbl
> group by computername, event order by computername, numb_times limit 3;
>
> But that wasn't the answer.  Can I do this is one sql statement?  Or am
> I going to have to make temp tables or multiple select statements?

Try this:

http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to