Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End problem in select from mysql_database

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #41706
    amis
    Participant

    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

    #119561
    Andy Howells
    Participant
    #119563
    amis
    Participant

    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”)

    #119567
    amis
    Participant

    this is what i want

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

    #119568
    amis
    Participant

    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)
  • The forum ‘Back End’ is closed to new topics and replies.