>Hi all,
>
>I'm trying to get a query to work but am having no luck.  It seems so
>simple, it should work, but obviously, I'm doing something wrong.
>
>Table: Employees
>  Fields: FirstName
>          LastName
>          EmployeeID
>
>
>Table: Sales
>  Fields: SubTotal
>          EmployeeID
>
>
>What I want to do is join the tables by the EmployeeID, Sum the SubTotal
>Field by EmployeeID and order the rows by the subtotal in DESC order to show
>the employee with the highest sales volume first.
>
>I'm using Win2k & MyODBC
>
>Any help would be greatly appreciated.

Sir, try
    SELECT e.EmployeeID, Sum(s.SubTotal) AS sum_st
    FROM Employees AS e INNER JOIN Sales AS s
       ON e.EmployeeID = s.EmployeeID
    GROUP BY e.EmployeeID
    ORDER BY sum_st;

>BTW,
>       Is LIMIT MySQL's version of the TOP predicate?

More or less. LIMIT can't return a percentage of the rows, and TOP 
can't return a specified count of rows starting at some arbitrary row.

Bob Hall

Know thyself? Absurd direction!
Bubbles bear no introspection.     -Khushhal Khan Khatak

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to