HomeInterview QuestionsGiven a table SCORE(ball INTEGER, score INTEGER) w…

Given a table SCORE(ball INTEGER, score INTEGER) with ball numbers and scores, write a SQL query to calculate the average score per over.

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

💡 Model Answer

You can compute the over number by dividing the ball number by 6 and rounding up. Then group by that over number and calculate the average score. For example:

SELECT over, ROUND(AVG(score), 2) AS avg_score_per_over

FROM (

SELECT ball, score,

     CEIL(ball / 6.0) AS over

FROM SCORE

) AS t

GROUP BY over

ORDER BY over;

This query assigns each ball to its over, groups the rows by over, and returns the average score for each over.

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