Find Students with Missing Contact InfoEasy

Find Students with Missing Contact Info

EasySQLPractice library · +10 XPnull handlingsqlfiltering

The 'UptoSkills Arena' college keeps track of its student's contact information. However, sometimes student records might not be complete. Your task is to find all students who have either their email address or their phone number missing (recorded as NULL).

  • students table:
    • student_id (integer, primary key)
    • first_name (varchar(50))
    • last_name (varchar(50))
    • email (varchar(100))
    • phone_number (varchar(20))

Return the student_id, first_name, and last_name for all such students. The order of the results does not matter. Handle NULLs by including records where either email or phone_number is NULL. Empty results should be returned as an empty set.

Tables

CREATE TABLE students (
  student_id integer PRIMARY KEY,
  first_name varchar(50) NOT NULL,
  last_name varchar(50) NOT NULL,
  email varchar(100),
  phone_number varchar(20)
);

Example data

INSERT INTO students (student_id, first_name, last_name, email, phone_number)
VALUES
(1, 'Aarav', 'Sharma', '[email protected]', '9876543210'),
(2, 'Diya', 'Patel', NULL, '8765432109'),
(3, 'Kabir', 'Singh', '[email protected]', NULL),
(4, 'Ananya', 'Verma', '[email protected]', '7654321098'),
(5, 'Rohan', 'Jain', NULL, NULL),
(6, 'Pari', 'Gupta', '[email protected]', '6543210987');

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

Hints