← Quiz: Checking AI-Written SQL: all 10 questions
Quiz: Checking AI-Written SQL · Question 3 of 10
What does this print? (code)
What does this print?
import sqlite3
db = sqlite3.connect(":memory:")
db.executescript("CREATE TABLE s (id INT); CREATE TABLE sub (sid INT); INSERT INTO s VALUES (1); ")
print(db.execute("SELECT COUNT(*), COUNT(sub.sid) FROM s LEFT JOIN sub ON sub.sid = s.id").fetchone())
- A.(0, 0)
- B.(1, 0)
- C.(1, 1)
- D.(0, 1)
Answer & explanation
Correct answer: (1, 0)
The LEFT JOIN makes one row with NULL in sub.sid; COUNT(*) counts it, COUNT(sub.sid) skips it.
Can you get the rest right without peeking?
Take the timed Quiz: Checking AI-Written SQL quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →