Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Start free
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

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.