Consider the table BATSMAN with the following sample records: Table:…
2026
Consider the table BATSMAN with the following sample records:
Table: BATSMAN
PayerID | PName | Match | B_Avg | Fifty | Century |
|---|---|---|---|---|---|
103 | J P Singh | 103 | 56 | 16 | 10 |
112 | Harpreet Kaur | 34 | 43 | 7 | 5 |
125 | Gems Gomez | 14 | 87 | 4 | 3 |
(Note: The table contains additional records.)
Write appropriate MySQL queries to perform the following tasks:
(A) Display the complete details of all batsmen whose batting average (B_Avg) is greater than or equal to 50.
(B) Display the average batting average (B_Avg) of all batsmen.
(C) Display the maximum total runs scored by any batsman, where total runs are calculated as (Match × B_Avg).
(D) Display the complete details of all batsmen in descending order of their batting average (B_Avg).
Attempted by 21 students.
Show answer & explanation
(A) Query for B_Avg ≥ 50
• Use SELECT with WHERE condition
• Filter records where B_Avg ≥ 50
SQL Query:
SELECT * FROM BATSMAN
WHERE B_Avg >= 50;
(B) Average Batting Average
• Use aggregate function AVG()
• Applies on entire column
SQL Query:
SELECT AVG(B_Avg) AS Average_Batting_Avg
FROM BATSMAN;
(C) Maximum Total Runs
• Total runs calculated using expression (Match * B_Avg)
• Use MAX() to find highest value
SQL Query:
SELECT MAX(Match * B_Avg) AS Max_Runs
FROM BATSMAN;
(D) Descending Order Display
• Use ORDER BY clause
• DESC keyword for descending order
SQL Query:
SELECT * FROM BATSMAN
ORDER BY B_Avg DESC;