Find Students with Missing Contact Info
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).
studentstable: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
-- Select students with incomplete contact information
SELECT student_id, first_name, last_name
FROM students
Your query runs on the example tables shown with the problem, then on hidden datasets when you submit.
Write standard SQL. MySQL habits work too: IFNULL, IF, YEAR(), DATE_FORMAT, GROUP_CONCAT, `backticks` and LIMIT 5, 10. It runs on PostgreSQL, so integer division keeps whole numbers (5 / 2 = 2): write 5.0 / 2 for 2.5.