count row

Discussion in 'Databases' started by roice, Aug 16, 2010.

  1. #1
    Hello,
    I have table for sells, that include: id, user_id, date (linux time)
    each record in the DB is 1 sell
    I want to print the user_id of the 10 users who made the top sells (the onces that have the biggest number of row that include the date of this month)

    how can I do that using PHP and MYSQL?
     
    roice, Aug 16, 2010 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    SELECT user_id, COUNT(user_id) AS user_count FROM my_table
    WHERE `date` = '2010-08-16'
    GROUP BY user_id
    ORDER BY user_count DESC
    LIMIT 10;
     
    jestep, Aug 16, 2010 IP
  3. seo-india

    seo-india Banned

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Dear read count function in database select column, count(column name) from table name condition
     
    seo-india, Aug 26, 2010 IP