PostgreSQL - Aggregate Functions and GROUP BYWhich of the following is the correct syntax to count all rows in a table named employees?ASELECT AVG(*) FROM employees;BSELECT SUM(*) FROM employees;CSELECT COUNT(*) FROM employees;DSELECT MAX(*) FROM employees;Check Answer
Step-by-Step SolutionSolution:Step 1: Recall syntax for counting rowsCOUNT(*) counts all rows regardless of NULLs.Step 2: Check other functionsSUM, AVG, MAX require column names and do not count rows.Final Answer:SELECT COUNT(*) FROM employees; -> Option CQuick Check:COUNT(*) = Counts rows [OK]Quick Trick: Use COUNT(*) to count all rows [OK]Common Mistakes:Using SUM(*) which is invalidUsing AVG(*) which is invalidUsing MAX(*) which is invalid
Master "Aggregate Functions and GROUP BY" in PostgreSQL9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PostgreSQL Quizzes Aggregate Functions and GROUP BY - GROUPING SETS for multiple groupings - Quiz 9hard Aggregate Functions and GROUP BY - FILTER clause for conditional aggregation - Quiz 4medium Common Table Expressions - Recursive CTE for hierarchical data - Quiz 3easy Full-Text Search - Highlighting with ts_headline - Quiz 2easy JSON and JSONB - Why JSON support matters in PostgreSQL - Quiz 4medium JSON and JSONB - JSONB containment (@>) operator - Quiz 5medium JSON and JSONB - Arrow operators (-> and ->>) - Quiz 4medium Set Operations and Advanced Queries - Conditional INSERT with ON CONFLICT - Quiz 9hard Set Operations and Advanced Queries - Why set operations matter - Quiz 8hard Window Functions in PostgreSQL - Named windows with WINDOW clause - Quiz 1easy