An HR analytics team is preparing a compensation report. The company database has two tables: Departments (dept_id, dept_name) and Employees (emp_id, dept_id, salary). The analyst must create a query that shows every department name together with the average salary of its employees, even when a department currently has no employees. Which SQL operation should be used to combine the tables before calculating AVG(salary) to satisfy this requirement?
Create a CROSS JOIN of Departments and Employees and filter on dept_id in a WHERE clause.
Combine the tables with UNION ALL on dept_id and then GROUP BY dept_name.
Use an INNER JOIN between Employees and Departments and then GROUP BY dept_name.
Perform a LEFT OUTER JOIN of Departments to Employees and then GROUP BY dept_name.
A left (outer) join keeps all rows from the Departments table and adds matching rows from Employees. Rows without a match get NULLs for employee columns, allowing AVG(salary) to return NULL (or be handled with COALESCE) while still listing the department. An inner join would drop departments that lack employees, a UNION stacks rows vertically instead of adding salary data side-by-side, and a cross join produces a Cartesian product that greatly inflates the result set and still requires an extra filter. Therefore, the left outer join is the only operation that guarantees every department remains in the aggregated result.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is a LEFT OUTER JOIN in SQL?
Open an interactive chat with Bash
How does AVG(salary) handle NULL values in SQL?
Open an interactive chat with Bash
Why wouldn’t an INNER JOIN work for this query?
Open an interactive chat with Bash
CompTIA Data+ DA0-002 (V2)
Data Acquisition and Preparation
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99 $11.99
$11.99/mo
Billed monthly, Cancel any time.
$19.99 after promotion ends
3 Month Pass
$44.99 $26.99
$8.99/mo
One time purchase of $26.99, Does not auto-renew.
$44.99 after promotion ends
Save $18!
MOST POPULAR
Annual Pass
$119.99 $71.99
$5.99/mo
One time purchase of $71.99, Does not auto-renew.
$119.99 after promotion ends
Save $48!
BEST DEAL
Lifetime Pass
$189.99 $113.99
One time purchase, Good for life.
Save $76!
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .