ExamBank Scot · AH Computing Science question bank · All AH Computing Science questions
11 marks · SELECT queries
The SQL query below is used to find the total sales made by each salesperson who did not meet their target in March 2025. SELECT Salesperson.name, SUM(salePrice) FROM Salesperson, Order WHERE Salesperson.salesID = Order.salesID AND __________________________________________ GROUP BY Salesperson.name _______________________________________________ ; Using appropriate Advanced Higher operators, write the missing conditions needed to complete this query. The company is running a promotion for their sales team. A salesperson who sells a car for a higher salePrice than the most expensive Goudi or CNX sold during April 2025 will receive a 5% bonus. Below is the incomplete query used to identify sales staff who are due to receive a bonus. SELECT Salesperson.name FROM Salesperson, Order, Car WHERE Salesperson.salesID = Order.salesID AND Car.carReg = Order.carReg AND ________A________ ( SELECT MAX(salePrice) FROM Order, Car WHERE availability = "Sold" AND date LIKE "2025-04-%" AND _______B___________ GROUP BY make ); Using appropriate Advanced Higher operators, write the SQL code needed to complete the missing conditions A and B. The following query is used to identify customers who may be ready to purchase an environmentally friendly car. SELECT Customer.name, date, make, model FROM Customer, Order, Car WHERE Customer.customerID = Order.customerID AND Car.carReg = Order.carReg AND NOT EXISTS( SELECT Customer.name FROM Customer WHERE (fuelType = "Hybrid" OR fuelType = "Electric") AND (date LIKE "2024-%-%" OR date LIKE "2023-%-%") ); Explain how the subquery, with the use of NOT EXISTS, generates the required results. Orders are placed using an online database-driven website. To access the ordering system, a salesperson must first login securely. The HTML form used for this purpose is shown below. Email: Password: Submit Below is the incomplete HTML form code. <form action = "login.php" _________A___________> Email: <input type="text" id="email" name="email" size="50" required > <br> Password: <input type="text" id="password" name="password" size="20" required> <br> <_____________B_____________> <br> </form> Write HTML code needed to complete the missing parts A and B. Explain the need for integrative testing when developing a database-driven website. Describe how end-user testing would be carried out on a database-driven website. A car company uses a relational database to record details of their sales. A sample of data stored in each table of the database is shown below. Car carReg make model recommendedPrice fuelType colour availability S81CGD CNX Fincas 18566 Petrol Black Sold HS75 TRF River Duke 24899 Electric Blue Pending RV36 NJU Goudi E3 26399 Hybrid Red Available … … … … … … … Order orderID customerID carReg salesID salePrice date orderID 1002 556 TR78 NGP 3 15239 2023-08-24 1002 1003 32 WR75 BCZ 7 17889 2024-11-03 1003 … … … … … … … Salesperson salesID name email password targetSales 1 Brendan Anderson banderson@rmail.com !Brendan62 90000 2 Marisa MacDonald mmacdonal@rmail.com MaR!$a123 88000 3 Andrew Partridge apartridge@rmail.com AP1994 105000 4 Anthony Phillips aphillips@rmail.com Florida2025 65000 … … … … … Customer customerID name phone email 134 Caroline Wilson 07732953435 cw12312@kaloo.co.uk 135 Jude Brady 07478251489 jbrady1504@warmail.com 136 Aidan Abrol 07835294648 aab12345@ct.co.uk … … … …
See sample solution below. Award 1 mark for correct use of BETWEEN Do not accept LIKE as it is not an AH concept. Award 1 mark for correct use of HAVING Note: ignore incorrect date formats. date BETWEEN '2025-03-01' AND '2025-03-31' HAVING SUM(salePrice) < targetSales A: salePrice > ANY B: make IN('Goudi', 'CNX') Award 1 mark for correct use of ANY Award 1 mark for correct use of IN • the subquery generates a list of customers who purchased environmentally friendly cars in 2023 or 2024 • NOT EXISTS ensures that only customers NOT found in the subquery appear in the query answer table. If a customer is absent from the subquery they will be included in the final output Award 1 mark for an explanation of how the sub query generates initial results. Award 1 mark for an explanation of how NOT EXISTS is used in the outer query. See sample solution below. Award 1 mark for correct use of POST. Award 1 mark for input type and value. Note: responses with type = "submit" value = "Submit" is not required; the alternative response type = "button" and <button> both require Submit. A: method = "POST" B: <input type = "submit" value = "Submit"> OR B: <input type = "submit"> OR B: <input type="button">Submit OR B: <button>Submit</button> • integrative testing is needed for projects that require integration of separate components • in this situation, integrative testing is needed to verify data is passed correctly between the website and database Award 1 mark for description of integrative testing. Award 1 mark for data connection between website and database. End-user testing would be conducted at the end of the development, with the end users of the software using a live version of the solution and providing feedback to the developers. Award 1 mark for description that indicates role of end-users in providing feedback to the developers.