Grow your CSS skills. Land your dream job.

problem in select from mysql_database

  • # January 1, 2013 at 12:55 pm

    I have database with these value

    result_id | user_id | degree


    1 | 1 | 40
    2 | 4 | 30
    3 | 2 | 10
    4 | 2 | 50
    5 | 1 | 60
    6 | 1 | 20
    7 | 2 | 70
    8 | 4 | 10
    9 | 4 | 30
    10 | 2 | 40

    I want to know the total degree of each user_id
    and then show the highest users having degree for this week , month and year

    # January 1, 2013 at 12:57 pm

    http://whathaveyoutriedsofar.com/

    # January 1, 2013 at 1:10 pm

    i have been tried more than 2 hours in these

    this is the last thing i do but not do what i want

    (“SELECT DISTINCT user_id, degree ORDER BY degree DESC”)

    # January 1, 2013 at 2:49 pm

    this is what i want

    SELECT user_id, SUM(degree) as totalMarks
    FROM results
    GROUP BY user_id
    ORDER BY SUM(degree) DESC

    # January 1, 2013 at 2:51 pm

    in addition to this

    WHERE date > DATE_SUB(NOW(), INTERVAL 1 WEEK)
    WHERE date > DATE_SUB(NOW(), INTERVAL 1 MONTH)
    WHERE date > DATE_SUB(NOW(), INTERVAL 1 YEAR)

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".