
Answer-first summary for fast verification
Answer: 3
The query: ```sql SELECT COUNT(DISTINCT *) FROM user ``` is asking **how many distinct rows** exist in the table. #### Key concept (important for Databricks / Spark SQL): - `DISTINCT *` means Spark compares **entire rows**, not individual columns. - `COUNT(DISTINCT ...)` counts how many **unique rows** exist. - Unlike `COUNT(column)`, this does **not** exclude rows just because they contain `NULL`. #### Row-by-row analysis: | Row | userId | username | email | Distinct? | |----|--------|--------------|------------------|-----------| | 1 | 1 | john.smith | john.smith@com | ✅ | | 2 | 2 | NULL | david.clear@com | ✅ | | 3 | 3 | kevin.smith | kevin.smith@com | ✅ | All **three rows are different**, even though one row contains `NULL`. ✅ **Correct Answer: A (3)** #### Why the others are wrong: - **B (2)**: Incorrect—no duplicate rows exist. - **C (1)**: Would require all rows to be identical. - **D (NULL)**: `COUNT` never returns `NULL`.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.