Quiz di SQL: COUNT(*) vs COUNT(column)

COUNT(*), COUNT(column) and COUNT(DISTINCT column) look alike but count different things. This SQL quiz tests how each one treats NULL, empty strings and duplicates, with a classic trap or two.

Medio 10 domande ~6 minuti Superato con il 80% SQLite

Scegli una modalità

Stai giocando come ospite: accedi per salvare XP e serie.

Domanda di esempio

Domanda 1 di 10

What does this query return?

CREATE TABLE customers (name TEXT, email TEXT, phone TEXT);
INSERT INTO customers VALUES ('Ana', 'a@x.com', NULL), ('Ben', NULL, NULL), ('Cy', 'c@x.com', '555'), ('Dee', 'a@x.com', NULL);
SELECT COUNT(*), COUNT(email) FROM customers;
Mostra la risposta

D. 4|3 COUNT(*) counts all 4 rows. COUNT(email) skips the row where email is NULL, so it returns 3.

Cosa copre questo quiz

  • COUNT(*) counts rows, COUNT(column) counts non-NULL values
  • COUNT(DISTINCT column) and duplicates
  • COUNT(1) is the same as COUNT(*)
  • Finding missing values with COUNT(*) - COUNT(column)
  • Empty strings are not NULL

Domande frequenti

Serve un account?

No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.

Posso rifarlo?

Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.