← Back to SELECT Basics
Question 39
Everyone Outside CS and Math
Everyone Outside CS and Math
Returnfirst_name,last_nameandmajor_department_idfor every student whose major is neither Computer Science (department 1) nor Mathematics (department 2). The four students with no declared major are also outside those two departments and must appear, with NULL in the third column;NOT INalone drops them, because NULL compared with anything is unknown rather than true. Sort bylast_name, thenfirst_name.
Expected result:
+------------+-----------+---------------------+ | first_name | last_name | major_department_id | +------------+-----------+---------------------+ | Henry | Adeyemi | 4 | | Zoe | Campbell | 3 | | Elijah | Costa | 3 | | Mia | Haddad | 3 | | Benjamin | Ivanov | NULL | | Scarlett | Johnson | 6 | | Noah | Kim | NULL | | Abigail | Larsen | 5 | | Ella | Murphy | 3 | | Mason | Nguyen | 5 | +------------+-----------+---------------------+ (showing 10 of 17 rows)
Hints4 available
Sign in to use hintsTopics:
SELECT Basics
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sel, ins, desc)
Results
Run your SQL to see every statement's output here, then how it compares with the expected answer.
Not sure what is in a table? SHOW TABLES lists them and DESCRIBE students shows the columns — or open the database browser on the left.