FastPrepBrands With Continuously Increasing Sales

Brands With Continuously Increasing Sales

Mastercard logoMastercard● MediumFULLTIMEPHONE SCREEN

Problem statement

Each row in brand_sales contains one brand's total sales for one calendar month.

Return the brands that have at least three recorded months, whose recorded months are immediately consecutive, and whose sales amount increases strictly every month.

Return one row per qualifying brand.

Table schema

MySQLPostgreSQLPandas

Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.

brand_sales

Contains one monthly sales total per brand.

ColumnTypeNullableDescription
brand_idPKIntegerNo—
sale_monthPKDateNo—
sales_amountDecimalNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
brand_idIntegerNo—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • (brand_id, sale_month) is unique.
  • sales_amount is nonnegative.
  • A brand must have at least three immediately consecutive calendar months.
  • Every sales amount must be strictly greater than the previous month's amount.
  • Sort by brand_id ascending.

More Mastercard problems

See Mastercard hiring insights