FastPrepTop Three Sales per County and Year
Problems/Top Three Sales per County and Year

Top Three Sales per County and Year

Clickhouse logoClickhouse● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: Reported in a Clickhouse phone screen. The report gives the table, the columns, the date range, the goal of the top three per county and year, and the output order. The report does not define groups smaller than three, so we guarantee at least three rows in range for every county and year that appears. We also changed how the year is taken from a date so it works in the languages we support. Our version is about 94% the same as the reported question.

The uk_price_paid table contains UK property sales with a sale date, county, and price.

For every county and calendar year from 2020 through 2022, return the three most expensive sales. Rank sales independently inside each county-year group.

Return county, sale_year, and price. Order the result by county ascending, sale_year ascending, and price descending.

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.

uk_price_paid

UK property sales used for the ranking query.

ColumnTypeNullableDescription
dateDateNoProperty sale date.
countyTextNoCounty containing the property.
priceIntegerNoRecorded sale price.

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
countyTextNo—
sale_yearIntegerNo—
priceIntegerNo—

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

Constraints

  • Each row has a non-null date, county, and positive integer price.
  • Every county-year group represented from 2020 through 2022 contains at least three rows.
  • Rows outside 2020 through 2022 are ignored.
  • If prices tie, any three tied source rows may be selected; because the result contains only county, year, and price, tied rows are indistinguishable.
  • Each testcase contains at most 2,000 rows.

Similar questions at other companies

  • Nth Highest SalaryPaytm · PHONE SCREENPaytm interview questions
  • Email Funnel: Opened Within a Day, Replied Within a WeekSuperhuman · PHONE SCREENSuperhuman interview questions
  • iPhone Model Sales Share by CountryApple · PHONE SCREENApple interview questions
  • Top Three Accounts by Monthly Transaction AmountMastercard · PHONE SCREENMastercard interview questions
  • In-Memory Database QueriesOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Block Type with the Most ChildrenNotion · PHONE SCREENNotion interview questions
  • Third-Highest Known SalaryAdobe · PHONE SCREENAdobe interview questions
  • Days Between Each User's Latest Two PostsZip · PHONE SCREENZip interview questions
  • Observed-User Percentage by AppMicrosoft · PHONE SCREENMicrosoft interview questions
  • Nth-Highest Book Sales VolumeAmazon · PHONE SCREEN

Clickhouse interview experiences

  • Onehouse SRE Interview: 1 Experience (Part 2 of 2)
  • Onehouse SWE OA and Interviews: 5 Experiences (Part 1 of 2)
See Clickhouse hiring insights