🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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())
  1. A.(0, 0)
  2. B.(1, 0)
  3. C.(1, 1)
  4. 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 →