HomeInterview QuestionsWe have a table called score with two columns: bal…

We have a table called score with two columns: ball (ball number) and score (score made on that ball). How would you calculate the average score per over?

🟡 Medium Coding Junior level
1Times asked
Jun 2026Last seen
Jun 2026First seen

💡 Model Answer

Assuming the table score has columns ball (integer) and score (integer), you can compute the average score per over using integer division to derive the over number. In SQL:

SELECT ((ball - 1) / 6) + 1 AS over,
       AVG(score) AS avg_score
FROM score
GROUP BY over
ORDER BY over;

Explanation: (ball - 1) / 6 gives the zero‑based over index because the first six balls belong to over 0. Adding 1 converts it to a 1‑based over number. AVG(score) calculates the mean score for each over. The query runs in O(n) time with a single scan of the table and uses O(k) space for the grouping, where k is the number of overs.

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 — invisible to screen sharing.

Get Assisting AI — Starts at ₹500