← Back to SELECT Basics
Question 34
Toronto or Ottawa but Not Graduated
Toronto or Ottawa but Not Graduated
Returnfirst_name,last_name,cityandstatusfor students who live in Toronto or Ottawa and whosestatusis notgraduated. Combine the two cities withOR, wrap that in parentheses, and attach the status rule withAND NOT; without the parentheses, the graduated Toronto student slips through. Sort bycity, thenlast_name.
Expected result:
+------------+-----------+---------+--------+ | first_name | last_name | city | status | +------------+-----------+---------+--------+ | Charlotte | Dubois | Ottawa | active | | Grace | Lee | Ottawa | active | | Ella | Murphy | Ottawa | active | | Sophia | Rossi | Ottawa | active | | Harper | Singh | Ottawa | active | | Elijah | Costa | Toronto | active | | Lucas | Fernandes | Toronto | active | | Scarlett | Johnson | Toronto | active | | Noah | Kim | Toronto | active | | Leo | Martin | Toronto | active | +------------+-----------+---------+--------+ (showing 10 of 12 rows)
Hints3 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.