Bird
0
0

Which of the following is the correct syntax to count all rows in a table named employees?

easy📝 Syntax Q3 of 15
PostgreSQL - Aggregate Functions and GROUP BY
Which 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;
Step-by-Step Solution
Solution:
  1. Step 1: Recall syntax for counting rows

    COUNT(*) counts all rows regardless of NULLs.
  2. Step 2: Check other functions

    SUM, AVG, MAX require column names and do not count rows.
  3. Final Answer:

    SELECT COUNT(*) FROM employees; -> Option C
  4. Quick Check:

    COUNT(*) = Counts rows [OK]
Quick Trick: Use COUNT(*) to count all rows [OK]
Common Mistakes:
  • Using SUM(*) which is invalid
  • Using AVG(*) which is invalid
  • Using MAX(*) which is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes