ExamBank Scot · Higher Computing Science question bank · All Higher Computing Science questions
2 marks · Aggregate functions and grouping
A TV network uses a relational database to store data about its TV programmes. One of the tables is shown below. Programme title year genre duration Dr Whitlet 2019 Sci-Fi 45 Game of Action 2020 Drama 30 My Life 2023 Romance 50 Island Life 2024 Drama 50 Red Mirror 2024 Drama 45 Real Love 2023 Romance 40 Kim 2021 Romance 60 The Dark Sky 2023 Sci-Fi 90 Complete the table below showing the expected output from the following SQL statement. SELECT year, genre, MIN(duration) AS 'Shortest time' FROM Programme WHERE year > 2021 GROUP BY year, genre; year genre Shortest time
• grouping on year and genre to return three rows • corresponding values for shortest time year genre shortest time 2023 2023 2024 Romance Sci-Fi Drama 40 90 45 Results can be in any order.