0
← Exercises/
CTEs•8 of 12
CTEsAdvancedPRO

Power User Identification via Cross-Module Adoption

Scenario

Product managers identify 'Power Users' as individuals who actively use at least 3 distinct product feature modules and generate at least 10 total interactions.

Task
Write a CTE query to filter and identify power users from `user_activity_stream`. Calculate: 1. `user_id` 2. `distinct_modules`: Count of distinct `module_name` used 3. `total_actions`: Total event count Only keep users where `distinct_modules >= 3` AND `total_actions >= 10`. Order results by `total_actions` descending, then by `user_id` ascending.
Expected Output Format

Power users utilizing at least 3 distinct modules and logging >= 10 actions.

Input Tables & Sample Data0 tables
Loading database schema...
Need a hint?
query.sql|Local Sandbox
Loading SQL editor...
Click "Run" or press ⌘ + Enter to execute your query

About the “Power User Identification via Cross-Module Adoption” SQL Problem

Business Scenario

Product managers identify 'Power Users' as individuals who actively use at least 3 distinct product feature modules and generate at least 10 total interactions.

Expected Output & Criteria

Power users utilizing at least 3 distinct modules and logging >= 10 actions.

Database Table Schema (PostgreSQL DDL)

PostgreSQL 16 WASM

This challenge executes directly against the following relational schema in your browser:

CREATE TABLE user_activity_stream (
        event_id INT PRIMARY KEY,
        user_id INT NOT NULL,
        module_name VARCHAR(50) NOT NULL
      );

Target SQL Clauses & Operators

WITHGROUP BYHAVING

Want more CTEs practice?

Explore the full syllabus of 12 exercises, syntax guides, and interview pitfalls.

View CTEs Track→