Write a SQL query to find the total marks for Maths only from the student table.
💡 Model Answer
Assuming a table named student with columns student_id, subject, and marks, the query to sum Maths marks is:
SELECT SUM(marks) AS total_math_marks
FROM student
WHERE subject = 'Maths';
This filters rows to only those where the subject is Maths and then aggregates the marks. The query runs in O(n) time, where n is the number of rows in the student table. Adding an index on the subject column can speed up the WHERE clause for large datasets. The result is a single value representing the total Maths marks, which can be used in reports or further calculations.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500