#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    1
    Rep Power
    0

    Peak hours of Top Sellers


    Hi,

    I have a table with the fields:
    id | hour | min | description | qty | total

    SELECT description, count(*), sum(total),
    FROM t_transaction GROUP BY description ORDER BY count(*) DESC LIMIT 30

    This works great getting the top sellers, but now I also want to find the peak hours for the top sellers. I've tried many different ways but cannot get it to work correctly. Any help would be appreciated, thanks in advance.
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,146
    Rep Power
    4274
    you apparently have successfully understood the COUNT() and SUM() aggregate functions

    have a look at MAX()
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo