GROUP BY ... HELP!

Help
2010-10-21
2013-06-03
  • Ken Goddard
    Ken Goddard
    2010-10-21

    I was wondering if you could help me. 

    I have a timesheet totals report that would have really benefited by the group by feature of SQL.   How can I produce the same results

    My Table:

    THIS IS THE WAY IT LOOKS NOW.
    EMPLOYEE_NO                 EMPLOYEE_NAME           EARN_CODE                       HOURS_MILES

    123                                         Joe Employee                    RG_TIME                             1.25
    123                                         Joe Employee                    RG_TIME                             1.25
    123                                         Joe Employee                    RG_TIME                             1.25
    123                                         Joe Employee                    RG_TIME                             1.25

    123                                         Joe Employee                    OT_TIME                             1.25
    123                                         Joe Employee                    OT_TIME                             1.25
    123                                         Joe Employee                    OT_TIME                             1.25

    THIS IS WHAT I NEED:  How do I accomplish this?
                                                                                                    (GROUPED BY                   SUM OF GROUPS)  This is what is accomplished by the group by mysql function
    EMPLOYEE_NO                 EMPLOYEE_NAME           EARN_CODE                       HOURS_MILES

    123                                         Joe Employee                    RG_TIME                             5

    123                                         Joe Employee                    OT_TIME                             3.75