FastPrepBlock Transaction Count Trends

Block Transaction Count Trends

Chainalysis logoChainalysis● MediumFULLTIMEONSITE INTERVIEW

Problem statement

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 problems

See Chainalysis hiring insights