Skip to main content

Activity 2.4A


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.

Using the student tables created earlier, create the following reports:

Part 1: How many students are there in the college?

Part 2: How many units in total have been passed?

Part 3: How many units has each student passed?

When creating the above reports, specify your own column headings rather than using the defaults.

Part 1

SELECT COUNT(*) "Total Students"

FROM student;

Output from SQL command

Part 2

SELECT COUNT(*) "Total Units Passed"

FROM result

WHERE result = 'P';

Output from SQL command

Part 3

SELECT student_number "Student", COUNT(unit_number) "Units Passed"

FROM result

WHERE result = 'P'

GROUP BY student_number;

Output from SQL command

Check your answer

Next: Activity 2.4B