0% found this document useful (0 votes)
17 views

Igcse Compsci 2ed TR Worksheet 9.2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Igcse Compsci 2ed TR Worksheet 9.2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CAMBRIDGE IGCSE™ & O LEVEL COMPUTER SCIENCE: WORKSHEET 9.

Name Date

9.2 SQL
These questions use the following database table, APPOINTMENT.

Appointment ID CustomerID Date Time Attended? Fee

56 3DF 10/10/2020 09:30 Yes 125.00

57 6HF 10/10/2020 10:45 Yes 220.00

58 7VD 11/10/2020 10:00 No 100.00

59 2SD 11/10/2020 12:15 No 160.00

60 9JK 11/10/2020 15:00 Yes 200.00

Getting started
Match the SQL queries to their output.

SELECT CustomerID 3DF


FROM APPOINTMENT 6HF
9JK

SELECT AppointmentID 3DF


FROM APPOINTMENT 6HF
ORDER BY Time 7VD
2SD
9JK

SELECT CustomerID 56
FROM APPOINTMENT 58
WHERE Attended? = Yes 57
59
60

Cambridge IGCSE™ & O Level Computer Science – Ellis © Cambridge University Press 2021 1
CAMBRIDGE IGCSE™ & O LEVEL COMPUTER SCIENCE: WORKSHEET 9.2

SELECT AppointmentID 57
FROM APPOINTMENT 56
WHERE Date = 10/10/2020
ORDER BY Time Desc

Match the following SQL queries to their output.

SELECT COUNT(Time) 260


FROM APPOINTMENT

SELECT SUM(Fee) 2
FROM APPOINTMENT
WHERE Attended? = No

SELECT SUM(Fee) 5
FROM APPOINTMENT
WHERE Date = 10/10/2020

SELECT COUNT(FEE) 345.00


FROM APPOINTMENT
WHERE FEE >= 200

Practice
Identify the output from the following SQL scripts:
1 SELECT Appointment ID, CustomerID
FROM APPOINTMENT
WHERE Date = 11/10/2020 AND Attended = No
2 SELECT Date, Time
FROM APPOINTMENT
WHERE Fee < 200
ORDER BY Fee DESC

Cambridge IGCSE™ & O Level Computer Science – Ellis © Cambridge University Press 2021 2
CAMBRIDGE IGCSE™ & O LEVEL COMPUTER SCIENCE: WORKSHEET 9.2

3 SELECT Appointment ID, CustomerID, Time, Attended?


FROM APPOINTMENT
WHERE Fee > 100 AND Fee < 200
4 SELECT Appointment ID, CustomerID
FROM APPOINTMENT
WHERE Date = 10/10/2020
ORDER BY Fee
5 SELECT COUNT(Appointment ID)
FROM APPOINTMENT
WHERE Attended? = No
6 SELECT SUM(Fee)
FROM APPOINTMENT
WHERE Time < 12:00

Challenge
Complete the following SQL scripts.
1 Return the Customer IDs of all customers attended an appointment on the 10/10/2020.

CustomerID

APPOINTMENT

Date = 10/10/2020

2 Return the Appointment IDs of customer 7VD

SELECT

FROM

WHERE Customer "7VD"

3 Return the Date and Time of all appointments on the 11/10/2020 where the fee is less
than 100.00

SELECT ,

FROM APPOINTMENT

WHERE Date 11/10/2020

Fee 100

Cambridge IGCSE™ & O Level Computer Science – Ellis © Cambridge University Press 2021 3
CAMBRIDGE IGCSE™ & O LEVEL COMPUTER SCIENCE: WORKSHEET 9.2

4 Return the Fee of all customers who attended appointments on the 10/10/2020 in
descending order of Time.

SELECT Fee

FROM APPOINTMENT

WHERE

Time

5 Return the total cost of all appointments.

SELECT ( )

FROM APPOINTMENT

6 Return the number of appointments between 10:00 and 13:00 inclusive.

SELECT (AppointmentID)

FROM APPOINTMENT

WHERE Time 10:00 Time 13:00

Cambridge IGCSE™ & O Level Computer Science – Ellis © Cambridge University Press 2021 4

You might also like