Data Transformation and Processing Logic Questions

Implementing transformation logic: joins, aggregations, deduplication, pivoting/reshaping, and business-rule application over datasets. Covers writing correct and maintainable transformation code, handling edge cases in the transform layer, and preparing data for downstream consumption. Focuses on the logic of turning raw data into analytics-ready outputs.

MediumTechnical
35 practiced

Given an orders table and a refunds table, compute net revenue per order date (or per month) applying the business rule that a refund reduces revenue on the original order's date, not the refund's date. Handle orders with no refunds, refunds with no matching order (flag them rather than silently dropping them), and partial refunds. As a related exercise: compute monthly revenue by region in a single reporting currency when orders carry mixed currencies and you must join to a table of historical FX rates, using the most recent rate on or before each order's date.

MediumTechnical
34 practiced

Implement a discount or promotion rule as deterministic, testable logic: for example, a line item qualifies for a discount only when several conditions all hold (a flag on the customer, a threshold on the order total, and a lookback window with no qualifying event). When multiple promotions could apply to the same item, the best discount should win. Provide an implementation (SQL or pseudocode) and describe how you would unit-test the rule set, including its edge cases.

MediumTechnical
30 practiced

Given a free-text address field with inconsistent layouts across countries, describe a strategy to parse and canonicalize it into structured components (street, city, region, postal code, country) suitable for matching and analytics, including how you would handle a case your approach can't confidently resolve. As a smaller related exercise, implement a general text-normalization function that trims whitespace, collapses repeated internal whitespace, strips control characters, and preserves Unicode letters and emoji.

MediumTechnical
28 practiced

Given a table of per-entity transactions (an entity id, an amount, and a timestamp), write a SQL query using window functions that computes a rolling N-day average or sum per entity per day, including days where the entity had no activity (rather than silently skipping them). Explain how you generate the calendar of dates needed for this and discuss the RANGE versus ROWS framing for the window.

MediumTechnical
28 practiced

Given a table of per-user transactions (amount, timestamp), write a SQL query using window functions that flags an outlier transaction as one where the amount exceeds the user's own historical mean plus 3 standard deviations, computed over a trailing period (e.g. the past 365 days). Explain how you handle a user with fewer than 2 prior transactions, and discuss why a simple z-score threshold can miss an outlier that a robust method like IQR would catch, since the outlier itself inflates the standard deviation used to judge it.

Unlock Full Question Bank

Get access to all 25 Data Transformation and Processing Logic interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.