The hockey organiser at your school requires your assistance with the administration of the players, teams and coaches - NSC Information Technology - Question 2 - 2019 - Paper 1
Question 2
The hockey organiser at your school requires your assistance with the administration of the players, teams and coaches.
The database HockeyDB contains two tables ca... show full transcript
Worked Solution & Example Answer:The hockey organiser at your school requires your assistance with the administration of the players, teams and coaches - NSC Information Technology - Question 2 - 2019 - Paper 1
Step 1
2.1.1 - Best players
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To find the best players, execute the following SQL query:
SELECT PlayerSurname, PlayerName FROM tblPlayers WHERE SkillsLevel = 10;
Step 2
2.1.2 - B-team coaches
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To retrieve B-team coaches, use this SQL query:
SELECT Coach, TeamName FROM tblTeams WHERE TeamName LIKE "%B%";
Step 3
2.1.3 - Percentage games won
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To calculate the percentage of games won, apply this query:
SELECT TeamName, Coach, (NumberOfGamesWon / NumberOfGamesPlayed * 100) AS PercentageGamesWon
FROM tblTeams WHERE TeamName = "" + TeamName;
Step 4
2.1.4 - Team average more than 6
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To find teams with an average skills level greater than 6, execute this query:
SELECT TeamName, ROUND(AVG(SkillsLevel), 1) AS AverageSkillsLevel
FROM tblPlayers
GROUP BY TeamName
HAVING AVG(SkillsLevel) > 6;
Step 5
2.1.5 - Update games won
97%
117 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To update the number of games won for a particular team, run this SQL command:
UPDATE tblTeams
SET NumberOfGamesWon = NumberOfGamesWon + 1
WHERE TeamName <> "u/14 B";
Step 6
2.2.1 - Junior players in u/18 A team
97%
121 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To count the number of junior players in the u/18 A team using Delphi:
Assign the tbl and Rewrite.
Set tblPlayers to start reading first record.
Loop while NOT tblPlayers.EOF:
Check if PlayerName is in "u/18 A" and if they are junior.
Display the count on the label.
Close the file.
Step 7
2.2.2 - Coach and goalkeeper information
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To display a list of coaches and goalkeepers:
Loop through tblTeams and tblPlayers respectively until EOF is reached.
Check if the TeamName matches and if a goalkeeper is present.
Output the relevant information in a formatted string.