SQL - Aggregate FunctionsWhich SQL query correctly counts the total number of rows in a table named orders?ASELECT COUNT(*) FROM orders;BSELECT COUNT(order_id) FROM orders WHERE order_id IS NULL;CSELECT COUNT(order_id) FROM orders;DSELECT COUNT(NULL) FROM orders;Check Answer
Step-by-Step SolutionSolution:Step 1: Identify query to count all rowsCOUNT(*) counts every row in the table, including those with NULLs.Step 2: Analyze other optionsCOUNT(order_id) counts only non-NULL order_id values; COUNT(NULL) is invalid and returns 0.Final Answer:SELECT COUNT(*) FROM orders; -> Option AQuick Check:COUNT(*) counts all rows [OK]Quick Trick: Use COUNT(*) to count all rows including NULLs [OK]Common Mistakes:MISTAKESUsing COUNT(column) to count all rowsUsing COUNT(NULL) which returns zeroFiltering with IS NULL incorrectly
Master "Aggregate Functions" in SQL9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More SQL Quizzes GROUP BY and HAVING - How GROUP BY changes query execution - Quiz 1easy INNER JOIN - INNER JOIN with table aliases - Quiz 7medium INNER JOIN - Joining on primary key to foreign key - Quiz 14medium INNER JOIN - INNER JOIN with ON condition - Quiz 3easy LEFT and RIGHT JOIN - LEFT JOIN vs RIGHT JOIN decision - Quiz 5medium Set Operations - Set operations with ORDER BY - Quiz 6medium Set Operations - UNION ALL with duplicates - Quiz 1easy Set Operations - UNION ALL with duplicates - Quiz 7medium Subqueries - Subquery in WHERE clause - Quiz 10hard Views - Updatable views and limitations - Quiz 2easy