Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7039077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:45:12+00:00 2026-05-28T01:45:12+00:00

I have following two tables (student and marks): In student table I have information

  • 0

I have following two tables (student and marks): In student table I have information about students and in marks table I have information about the marks that the students have got. Now could you please tell me how to find out who got the highest mark calculating the total obtained mark from marks table ?

Thanks in Advance 🙂

p.s. Some may find the question duplicate of this- how to find the highest value in mysql table but in my defense my question is slightly different. 🙂

Student Table:

studentid   student_name
 1001        Jon Bon Jovi
 1002        Charlie Sheen
 1003        Jason Statham
 ... Goes on like this

Marks Table:

id   studentid totalmark obtainedmark  
1     1001       20          12
2     1002       20          20
3     1003       20          15
4     1001       50          40
5     1002       50          50
6     1003       50          45     
... Goes on like this
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:45:13+00:00Added an answer on May 28, 2026 at 1:45 am

    This will return the person with the highest sum of obtained marks:

    SELECT s.studentid, s.student_name, SUM(m.obtainedmark) as c
    FROM students s INNER JOIN marks m ON s.studentid = m.studentid
    GROUP BY s.studentid
    ORDER BY c DESC
    LIMIT 1
    

    Looking at your table though, perhaps it is more useful to return the highest average test score returning their average percentage obtained. You can do this using the following I believe:

    SELECT s.userId, s.name, AVG( ( m.obtainedmark / m.totalmark ) ) as c
    FROM bnt_users s INNER JOIN bnt_user_skill_rating m ON s.userId = m.user_id
    GROUP BY s.userId
    ORDER BY c DESC
    LIMIT 2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following two tables that record expenditure and provide expenditure category information:
I have the following two tables in my mysql database. Table Name: groups id
I have the following two tables, affiliates and referrers. affiliates Table id loginid 3
Suppose I have the following two tables: STUDENT studentid lastname firstname 1 Smith John
I have two SQL tables Student and Class . In Student table, the fields
I have the following two tables Table: items ID | TITLE 249 | One
I have following two tables Table name: thread pk-> thread_id | thread_title | description
I have the following two tables, one stores order information, one stores key|value information.
I have the following two tables (SQL scripts with data): CREATE TABLE [dbo].[Item_Master]( [Item_Name]
I was wondering if someone could help me. I have the following two tables:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.