2.1 SQL statements
2.1.1 Button [2.1.1 - List of bookings]
Display the booking number and the learner driver name and surname of all bookings with Bellville as test venue - NSC Information Technology - Question 2 - 2022 - Paper 1
Question 2
2.1 SQL statements
2.1.1 Button [2.1.1 - List of bookings]
Display the booking number and the learner driver name and surname of all bookings with Bellville as test... show full transcript
Worked Solution & Example Answer:2.1 SQL statements
2.1.1 Button [2.1.1 - List of bookings]
Display the booking number and the learner driver name and surname of all bookings with Bellville as test venue - NSC Information Technology - Question 2 - 2022 - Paper 1
Step 1
Button [2.1.1 - List of bookings]
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 retrieve the booking number and learner driver details for all bookings in Bellville, use the following SQL query:
SELECT BookingNum, DriverName, DriverSurname
FROM tblBookings
WHERE TestVenue = 'Bellville';
Step 2
Button [2.1.2 - Update test venue]
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
The update query should be structured as follows to change the test venue to 'Headquarters' for records without a venue:
UPDATE tblBookings
SET TestVenue = 'Headquarters'
WHERE TestVenue IS NULL;
Step 3
Button [2.1.3 - Bellville bookings]
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 display the booking number and details for bookings in Bellville, the same query can be used from the previous step, as shown:
SELECT BookingNum, DriverName, DriverSurname
FROM tblBookings
WHERE TestVenue = 'Bellville';
Step 4
Button [2.1.4 - Licence types]
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 count the number of bookings for each type of licence, utilize the query:
SELECT LEFT(BookingNum, 1) AS LicenceType, COUNT(*) AS NumberOfBookings
FROM tblBookings
GROUP BY LEFT(BookingNum, 1);
Step 5
Button [2.1.5 - Remove bookings]
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 delete records from tblBookings where the TestVenue is 'Pretoria' and the BookingDate falls within the specified range:
DELETE FROM tblBookings
WHERE TestVenue = 'Pretoria'
AND BookingDate BETWEEN '2022-05-18' AND '2022-05-25';