Block Transaction Count Trends
Updated
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
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.
| Column | Type | Nullable | Description |
|---|---|---|---|
| block_heightPK | Integer | No | Unique Bitcoin block height. |
| transaction_count | Integer | No | Number of transactions in the block. |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| block_height | Integer | No | — |
| transaction_count | Integer | No | — |
| previous_transaction_count | Integer | Yes | — |
| trend | Text | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
btc_blockscontains from 1 through 2,000 rows.block_heightis a unique nonnegative integer.transaction_countis 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