MySQL Forums
Forum List  »  Optimizer & Parser

Re: left join with sum and group by
Posted by: Rick James
Date: August 27, 2010 08:01PM

Or, maybe I did not do the JOIN right...
SELECT a.date, a.weekday, a.workinghours,
       e.employee,
       sum(b.hours),
       sum(b.hours) - a.workinghours
    FROM a
    JOIN ( SELECT DISTINCT employee FROM b ) AS e
    LEFT JOIN b  ON a.date = b.date
                AND e.employee = b.employee   -- added this
    GROUP BY  a.date, e.employee

Options: ReplyQuote


Subject
Views
Written By
Posted
23951
August 18, 2010 05:46AM
8364
August 20, 2010 11:40PM
Re: left join with sum and group by
6603
August 27, 2010 08:01PM
4031
September 07, 2010 05:08AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.