Employee Query Activity Analysis
IBM 👶 Easy SQL
Beginner Mode

Objective

Write a SQL query to create a histogram of employee query activity for Q3 2023.

Table Schema:

  • employees
Column Type Description
employee_id INTEGER Unique identifier for each employee
employee_name VARCHAR Name of the employee
  • queries
Column Type Description
query_id INTEGER Unique identifier for each query
employee_id INTEGER ID of the employee who executed the query
query_text TEXT The SQL query text
execution_date DATETIME Date and time when the query was executed

Task Requirements:

  • Filter queries executed in Q3 2023 (July, August, September)
  • Count unique queries per employee
  • Include employees who executed zero queries
  • Count how many employees executed each number of unique queries
  • Sort results by query count in ascending order

Output columns: unique_queries, employee_count

Examples

Example 1:

Input:

employees
employee_idemployee_name
101Alice
102Bob
103Charlie
queries
employee_idexecution_datequery_idquery_text
1012023-07-15 10:00:001SELECT * FROM users
1012023-08-20 11:00:002SELECT * FROM orders
1022023-09-10 12:00:003SELECT * FROM products

Output:
employee_countunique_queries
10
11
12
Quick Solution

Code Environment

Sign in or try as guest to run your code.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →