Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL for Top Feature Usage
00:00
5 left

SQL for Top Feature Usage

MediumSQL · PostgreSQL

Problem

AvePoint wants to understand which product features are most used by its most active enterprise customers. Write a PostgreSQL query that considers usage during the 30-day period ending on September 15, 2026, identifies the three most active enterprise accounts, and returns the three most-used features among those accounts.

Output

  1. Return one row per feature with columns feature_name and usage_count.
  2. Include only usage events from August 17, 2026 through September 15, 2026, inclusive. Events with a null or unmatched feature are excluded from feature totals.
  3. Select the three enterprise accounts with the most usage events in that period. Break account-activity ties by account_id in ascending order.
  4. Return at most three features, ordered by usage_count descending and then feature_name ascending. Return fewer rows when fewer than three matched features exist.

Schema

accounts
ColumnTypeDescription
account_idPKVARCHAR(20)Unique customer account identifier
account_nameVARCHAR(150)Customer account name
account_typeVARCHAR(30)Customer segment, including enterprise
features
ColumnTypeDescription
feature_idPKVARCHAR(20)Unique feature identifier
feature_nameVARCHAR(100)Display name of the AvePoint feature
feature_usage
ColumnTypeDescription
usage_idPKINTUnique feature usage event identifier
account_idVARCHAR(20)Account associated with the usage event
feature_idVARCHAR(20)Feature associated with the usage event
occurred_atTIMESTAMPTimestamp when the feature was used
Tablesaccountsfeaturesfeature_usage
Interviewer

Your question is SQL for Top Feature Usage. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.