Skip to main content

Activity 2.3C

1

Inserting Records

Using the solution to Activity 1.5, found in the previous section, develop a command file to create the student table and insert records into that table. Use SQL to display the entered rows.

Produce the following reports:

Report 1: a list of those students (i.e. numbers and full names) for whom date of births are not recorded - sort the results by surname

Report 2: a list of those students (i.e. numbers and full names, together with their date of births) whose names start with the letter J, have a student number in the range 'L0001000' and 'L0002000' and whose date of births are recorded.

Report 1

SELECT student_number, title, forename, surname

FROM student

WHERE date_of_birth IS NULL ORDER BY surname;

Output from the SELECT student_number, title, forename, surname[D]

Report 2

SELECT student_number, title, forename, surname, date_of_birth

FROM student

WHERE surname LIKE 'J%'

AND student_number BETWEEN 'L0001000' AND 'L0002000'

AND date_of_birth IS NOT NULL;

Output from the SELECT student_number, title, forename, surname, date_of_birth FROM student WHERE surname LIKE 'J%' AND student_number BETWEEN 'L0001000' AND 'L0002000' AND date_of_birth IS NOT NULL; command

Check your answer

Next: Calculations