FastPrepBlock Transaction Count Trends
Problems/Block Transaction Count Trends

Block Transaction Count Trends

Chainalysis logoChainalysis● MediumFULLTIMEONSITE INTERVIEW

Updated Mar 2025

QuestionConstraints

Problem statement

Source note: A first-hand Chainalysis data-engineering onsite report gives the btc_blocks table and asks for the current transaction count, previous block count via LAG, and an Increased/Decreased/Same trend. Conventional block_height ordering plus the earliest-row NULL/Same rule are explicit practice assumptions; the reported core matches at about 94%.

The btc_blocks table records one Bitcoin block per row with its height and transaction count.

For every block, show its block_height, current transaction_count, and the preceding block row's transaction count as previous_transaction_count. Add a trend label: Increased, Decreased, or Same by comparing the current count with the previous count.

Order rows by block_height ascending. For the earliest block, return NULL as the previous count and Same as the trend.

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.

btc_blocks

Bitcoin blocks and their transaction counts.

ColumnTypeNullableDescription
block_heightPKIntegerNoUnique Bitcoin block height.
transaction_countIntegerNoNumber of transactions in the block.

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
block_heightIntegerNo—
transaction_countIntegerNo—
previous_transaction_countIntegerYes—
trendTextNo—

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

Constraints

  • btc_blocks contains from 1 through 2,000 rows.
  • block_height is a unique nonnegative integer.
  • transaction_count is a nonnegative integer.
  • The previous block means the preceding available row after sorting by block_height, even when heights are not consecutive.

More Chainalysis interview questions

  • Filter Team A LogsONSITE INTERVIEW · Seen Mar 2025
  • Filter Team A Transfer LogsONSITE INTERVIEW · Seen Mar 2025
  • High-Severity Counts by Search TypeONSITE INTERVIEW · Seen Mar 2025
  • Team A High-Severity Transfer HashesONSITE INTERVIEW · Seen Mar 2025
  • Meeting RoomsPHONE SCREEN · Seen Apr 2025
  • Meeting Rooms IIPHONE SCREEN · Seen Apr 2025
  • Course Schedule IIOA · Seen Nov 2022
  • Longest Common SuffixOA · Seen Nov 2022

Similar questions at other companies

  • Daily USD Totals with Effective-Dated Exchange RatesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Most Recent Order for Each CustomerCapgemini · ONSITE INTERVIEWCapgemini interview questions
  • Tenth-Highest Distinct SalaryInfosys · ONSITE INTERVIEWInfosys interview questions
  • Fifth Highest Salary In A DepartmentZS · ONSITE INTERVIEWZS interview questions
  • In-Memory Database QueriesOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Order Book Data ValidationJane Street · ONSITE INTERVIEWJane Street interview questions
  • Nth-Highest Distinct Salary Without Ranking FunctionsMastercard · ONSITE INTERVIEWMastercard interview questions
  • Contest Participants with Long Totals and Short QuestionsThe Walt Disney Company · ONSITE INTERVIEWThe Walt Disney Company interview questions
  • First Order per Merchant per DateAmazon · ONSITE INTERVIEW
  • Third-Highest Distinct SalaryExpedia · ONSITE INTERVIEWExpedia interview questions
All Chainalysis interview questionsSee Chainalysis hiring insights