A data analyst receives a request for the current employee head count and runs the following SQL statement: SELECT COUNT(EMPLOYEE_ID) FROM JOBS. The returned head count is higher than expected because employees can have multiple jobs. Which of the following should return an accurate employee head count?

Enhance your skills with the CompTIA Data+ Certification Test. Engage with flashcards, tackle challenging multiple choice questions, complete with hints and explanations. Get yourself exam-ready now!

Multiple Choice

A data analyst receives a request for the current employee head count and runs the following SQL statement: SELECT COUNT(EMPLOYEE_ID) FROM JOBS. The returned head count is higher than expected because employees can have multiple jobs. Which of the following should return an accurate employee head count?

Explanation:
Counting unique employees is the right approach when a person can appear in multiple job records. COUNT counts rows, and if an employee has multiple jobs, that one person would be counted multiple times. Using COUNT(DISTINCT EMPLOYEE_ID) collapses all rows for the same employee into a single count, giving the true headcount. If you grouped by job type, you’d get a separate count for each type rather than the overall total. If you tried a form of COUNT with DISTINCT in a way that doesn’t aggregate across all rows, you’d end up with either per-group counts or an invalid/simplified result, not the single overall headcount.

Counting unique employees is the right approach when a person can appear in multiple job records. COUNT counts rows, and if an employee has multiple jobs, that one person would be counted multiple times. Using COUNT(DISTINCT EMPLOYEE_ID) collapses all rows for the same employee into a single count, giving the true headcount.

If you grouped by job type, you’d get a separate count for each type rather than the overall total. If you tried a form of COUNT with DISTINCT in a way that doesn’t aggregate across all rows, you’d end up with either per-group counts or an invalid/simplified result, not the single overall headcount.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy