Coding time

Report a typo

We have four tables created using this code:

CREATE TABLE faculty_name (
  id SERIAL PRIMARY KEY,
  name VARCHAR(40) 
);

CREATE TABLE subject_type (
  id SERIAL PRIMARY KEY,
  name VARCHAR(40) 
);

CREATE TABLE students (
  id SERIAL PRIMARY KEY,
  name VARCHAR(40) ,
  faculty_id INT NULL REFERENCES faculty_name (id)
);


CREATE TABLE mark (
  id SERIAL PRIMARY KEY,
  student_id INT NULL REFERENCES students (id),
  subject_id INT NULL REFERENCES subject_type (id),
  mark INT
);

Retrieve the minimum, maximum, and average marks of each subject, along with the total number of students who took that subject.

The result set should contain 4 columns:

  • subject name (subject_name)

  • number of students (student_count)

  • maximum mark (max_mark)

  • minimum mark (min_mark)

  • average mark (avg_mark)

Write an SQL statement





___

Create a free account to access the full topic