Find Students with Missing Email AddressesEasy

Find Students with Missing Email Addresses

EasySQLPractice library · +10 XPnull handlingsqlfiltering

In a college database, student records are maintained. Some students might not have provided their email addresses.

Tables:

  • students (student_id, name, email, major)

Return the student_id and name of all students whose email is NULL. The results should be ordered by student_id.

If there are no students with missing email addresses, return an empty result set. Ties in student_id are not possible as it's a primary key. NULL values in the email column are explicitly handled.

Tables

CREATE TABLE students (
  student_id integer PRIMARY KEY,
  name varchar(100) NOT NULL,
  email varchar(100),
  major varchar(100)
);

Example data

INSERT INTO students (student_id, name, email, major)
VALUES
(1, 'Alice Smith', '[email protected]', 'Computer Science'),
(2, 'Bob Johnson', NULL, 'Physics'),
(3, 'Charlie Brown', '[email protected]', 'Mathematics'),
(4, 'Diana Prince', NULL, 'History'),
(5, 'Ethan Hunt', '[email protected]', 'Chemistry');

Your query is also checked on hidden datasets with different data.

Hints