Time/amount

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jas2803
    New Member
    • Oct 2007
    • 30

    Time/amount

    Hi all,
    I searched but not exactly sure what I am looking for but here it is basically:
    I have a couple of tables,
    Employee:
    [EmployeeID] [Fname][MI] [LName]....

    Call History:
    [EmployeeID] [Phone Number] [StartTime] [EndTime] (time stamp format)[QuantitySold]

    What I would like to do is create an sql for each employee id in employee, linked to Call history in such a way that would allow me to graph Quantity sold per hour.

    QTY
    10
    9
    8
    7.............. ............... .............. |
    6.............. ............... .............. |
    5.............. ............... .............. |
    4.............. ....|.......... ............... |
    3 ............... ..|............ .............|
    2........|..... ....|.......... ............... |
    1 .......|....... ..|..........| .............|
    0____|_ ___|_____|_____ __|________
    Hr 7 8 9 10 11 12 1 2 3 4 5
    So Employee 1 sold say 3 items between hours 7 and 8, 5 items between hours 9 and 10, 2 items between hours 11 and 12, and 8 items between hours2 and 3
    I am using MySQL and Excel. I would like to use bar graphs but to do this I need to show even zero values between 8/ 9, 10/11. 12/1, 1/2, 3/4, 4/5
    Does this make sense?
    Any ideas, any way to clarify this any better?

    Thanks
    Jas
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    I think this will give you what you want, in this case I don't think you will need the other Employee table:

    [code=sql]
    SELECT EmployeeID, DATE_FORMAT(End Time, '%d %m %y') As DateSold, DATE_FORMAT(End Time, '%h') As HourSold, Sum(QuantitySol d)
    FROM Call History
    GROUP BY EmployeeID, DATE_FORMAT(End Time, '%d %m %y'), DATE_FORMAT(End Time, '%h')
    ORDER BY DATE_FORMAT(End Time, '%d %m %y'), DATE_FORMAT(End Time, '%h')
    [/code]

    Comment

    Working...