Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Monthly Active Asset Growth Rate

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Monthly Active Asset Growth Rate. Start with the requirements and the two tables on the right.

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.

Problem

You are given deployment records for hardware assets and a reference table of assets. Write a PostgreSQL query to calculate the month-over-month growth rate of active hardware assets deployed in the field. Treat an asset as active in a month if it was deployed on or before the end of that month and has not been retired before that month ends. Only include assets whose current status is active and whose deployment location is field.

Return one row per month with the month, the count of active deployed assets, the previous month's count, and the month-over-month growth rate as a percentage. For the first month in the result, the previous month count and growth rate should be NULL.

Schema

hardware_assets
ColumnTypeDescription
asset_idPKINTUnique hardware asset identifier
asset_nameVARCHAR(100)Human-readable asset name
asset_typeVARCHAR(50)Type of hardware asset
statusVARCHAR(20)Current asset status such as active, retired, or maintenance
asset_deployments
ColumnTypeDescription
deployment_idPKINTUnique deployment record identifier
asset_idINTReferences hardware_assets.asset_id
deployed_atDATEDate the asset was deployed
retired_atDATEDate the deployment ended, if retired
location_typeVARCHAR(20)Deployment location classification such as field, lab, or staging
Tableshardware_assetsasset_deployments
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results