SQL Practice Logo

SQLPractice Online

Scenario SQL Question

Count Distinct Departments with Employees

Build mastery in Aggregations with this scenario-based SQL challenge and live execution support.

Problem Statement

Count how many distinct department_id values appear in the employees table (excluding NULLs). Return a single column named departments_with_employees.

Relevant Tables

employees

SQL Concepts Used in This Scenario

Strengthen your understanding with these targeted learning topics: