Choose a business question, inspect the original data, write a SQLite query and save a checked result. Related exercises share a scenario while asking for different decisions and output contracts.
Event sequence diagnostics
For each actor ordered by seq, return only events whose state differs from their immediate predecessor. Omit the first event; sort actor then seq.
Open task, files and full answers →Event sequence diagnostics
For consecutive stored sequence numbers per actor, report missing inclusive sequence ranges. A jump from 3 to 5 means missing 4, regardless of timestamps. Sort actor,missing_from.
Open task, files and full answers →Event sequence diagnostics
Report actor,seq,minute,previous_minute only when the event minute is less than the preceding sequence event minute. Sort actor,seq.
Open task, files and full answers →Event sequence diagnostics
A failure run is consecutive fail events in seq order. Return actor,first_fail_seq,recovery_seq,elapsed_minutes for each run that ends in ok. Time is recovery minute minus first-fail minute, even if negative. Sort actor,first_fail_seq.
Open task, files and full answers →Event sequence diagnostics
Report one longest_failures value per actor. Runs follow seq order and sequence gaps do not break a run; any ok state does. Sort actor.
Open task, files and full answers →Event sequence diagnostics
Treat delta as a signed ledger movement and opening balance as zero. Output actor,seq,balance after each sequence event, including negative and zero balances. Sort actor,seq.
Open task, files and full answers →Event sequence diagnostics
Calculate sequence-based running delta and report the first seq with balance<0 for each actor that ever becomes negative. Output actor,first_negative_seq; sort actor.
Open task, files and full answers →Event sequence diagnostics
Order each actor by minute then id. A gap strictly greater than 30 minutes starts a new session; exactly 30 stays in the same session. Return actor,id,session_no sorted actor,minute,id.
Open task, files and full answers →Event sequence diagnostics
For each event except the last in each actor sequence, return actor,seq,state,duration_minutes to the next sequence event. Preserve negative durations for clock review. Sort actor,seq.
Open task, files and full answers →Event sequence diagnostics
At minute 50 inclusive, choose each actor latest observed event by minute then largest id for a tie. Return actor,id,state; exclude events later than cutoff. Sort actor.
Open task, files and full answers →Intervals and scheduling
Within each resource merge half-open intervals when they overlap or touch. Output resource,start,end for the disjoint occupied islands, sorted resource,start.
Open task, files and full answers →Intervals and scheduling
For each resource return maximal unoccupied intervals inside [0,60). Treat touching bookings as continuous. Output resource,start,end sorted resource,start.
Open task, files and full answers →Intervals and scheduling
Bookings occupy [start,end); an end and start at the same minute do not overlap. Return resource,peak_concurrent from endpoint segments, sorted resource.
Open task, files and full answers →Intervals and scheduling
Split each resource at every start/end. For every occupied elementary segment choose highest priority, then smallest booking id. Output resource,start,end,winner_id; do not merge adjacent segments. Sort resource,start.
Open task, files and full answers →Intervals and scheduling
Return child_id,parent_id for strict containment on the same resource: parent starts no later, ends no earlier, and at least one boundary differs. List every enclosing parent; sort child_id,parent_id.
Open task, files and full answers →Intervals and scheduling
For each booking count the number of integer minutes in its own interval occupied by at least one other booking on the same resource. Count each minute once even if two others overlap. Output id,contested_minutes sorted id.
Open task, files and full answers →Intervals and scheduling
For each request search integer start minutes from its requested minute through 60-duration inclusive. Choose the first interval that overlaps no existing slot on its resource; NULL means no fit. Output request_id,start sorted request_id.
Open task, files and full answers →Intervals and scheduling
For each request attach all slots covering its requested minute using half-open semantics; retain unmatched requests with NULL booking_id. Output request_id,booking_id sorted by both.
Open task, files and full answers →Intervals and scheduling
Per resource choose an unweighted maximum-cardinality compatible booking set by earliest finishing time, ties by id. After each choice the next booking must start at or after the prior end. Return resource,kept_id sorted resource,kept_id.
Open task, files and full answers →Intervals and scheduling
For each request count every feasible integer start within [requested minute,60-duration] with no overlap. This is capacity of alternative placements, not simultaneous bookings. Output request_id,placement_options sorted request_id.
Open task, files and full answers →Recursive structures
For every hierarchy node return id,path from its root with slash separators. Include all roots and descendants. Sort id.
Open task, files and full answers →Recursive structures
Return only nodes without children, with their number of parent edges to the root. Output id,depth sorted id.
Open task, files and full answers →Recursive structures
Each node contributes its own cost once to itself and every ancestor. Return id,subtree_cost sorted id.
Open task, files and full answers →Recursive structures
For the fixed nodes 7 and 5 return their nearest common ancestor id. Distance is the number of parent edges; choose the common ancestor minimizing summed distance.
Open task, files and full answers →Recursive structures
Return src,dst for every edge whose destination can reach its source through one or more edges. Use set reachability so cycles terminate. Sort src,dst.
Open task, files and full answers →Recursive structures
Start at graph node 1. Paths must not repeat a node. Return node,min_cost for reachable destinations excluding 1, choosing minimum total edge weight over all simple paths. Sort node.
Open task, files and full answers →Recursive structures
For one KIT, recursively multiply quantities along paths and sum repeated leaf components. Return component,required_units for leaves only, sorted component.
Open task, files and full answers →Recursive structures
The graph node universe is every src and dst in edges. Starting at 1, return id for nodes not reachable, sorted id.
Open task, files and full answers →Recursive structures
For each root and depth, count nodes at that depth within its tree. Return root,depth,node_count sorted root,depth.
Open task, files and full answers →Recursive structures
An edge is redundant when a path from its src to dst exists after removing that exact edge. Return src,dst sorted. The alternate path must have at least two edges.
Open task, files and full answers →Basket analysis and allocation
Return order_id for baskets containing every SKU in required at least once, regardless of quantity. Sort order_id.
Open task, files and full answers →Basket analysis and allocation
Return order_id for nonempty baskets where every line is book. Presence of any other category excludes the whole basket. Sort order_id.
Open task, files and full answers →Basket analysis and allocation
For every pair of distinct SKUs in an order, count the number of orders containing that pair. Emit sku_a<sku_b,order_count sorted sku_a,sku_b. Each order contributes once per pair.
Open task, files and full answers →Basket analysis and allocation
For each basket with at least three total units, discount exactly one unit at its minimum unit price. Otherwise discount zero. Return order_id,gross_cents,discount_cents,net_cents sorted order_id.
Open task, files and full answers →Basket analysis and allocation
Per order and category, discount 10 percent of category gross capped at 100 cents. Integer division truncates fractional cents. Return order_id,discount_cents as the sum of category discounts, sorted order_id.
Open task, files and full answers →Basket analysis and allocation
Allocate a fixed 100-cent order credit across positive-gross lines in proportion to line gross. Floor each share, then assign residual cents to largest fractional remainders, ties by sku. Return order_id,sku,credit_cents; exclude zero-gross lines. Sort order_id,sku.
Open task, files and full answers →Basket analysis and allocation
A basket qualifies when it has at least two book units and at least one tool unit. Return order_id,book_units,tool_units for qualifiers sorted order_id.
Open task, files and full answers →Basket analysis and allocation
Compare every pair of orders a<b. Return order_a,order_b,intersection_count,union_count for pairs sharing at least one SKU. Quantities are ignored. Sort order_a,order_b.
Open task, files and full answers →Basket analysis and allocation
Free shipping requires 2000 cents of nongift merchandise. For every order return order_id,eligible_cents,topup_cents=max(0,2000-eligible). Sort order_id.
Open task, files and full answers →Basket analysis and allocation
Return order_id,distinct_categories,gross_cents,position. Position is a unique ranking by category count descending, gross descending, then order_id ascending. Sort position.
Open task, files and full answers →Statistical reporting contracts
For each team ignore NULL values and their weights. Return team,weighted_mean rounded to two decimals, using SUM(value*weight)/SUM(weight) over known values. Sort team.
Open task, files and full answers →Statistical reporting contracts
Return team,median over known values only. Sort known values numerically and average the two middle observations for even counts. Sort team.
Open task, files and full answers →Statistical reporting contracts
For each team sort known values and choose rank ceil(0.8*n), using one-based rank. Return team,p80 sorted team. No interpolation.
Open task, files and full answers →Statistical reporting contracts
Within each team remove exactly one smallest and one largest known observation, ties by id. Average remaining values rounded to two decimals. Return team,trimmed_mean sorted team.
Open task, files and full answers →Statistical reporting contracts
For known values per team compute AVG(value²)-AVG(value)², rounded to two decimals. This is population variance, not sample variance. Return team,population_variance sorted team.
Open task, files and full answers →Statistical reporting contracts
Per team/day order, take the current and two previous physical rows. Average known values in that frame and round to two decimals. Return team,day,moving_average sorted team,day.
Open task, files and full answers →Statistical reporting contracts
For each team/day return cumulative known_count and observed_rows through that row, sorted team,day. A known zero counts as known; NULL does not.
Open task, files and full answers →Statistical reporting contracts
For every known observation return team,id,value,dense_position using value descending within team, with equal values sharing a rank and no gaps. Sort team,dense_position,id.
Open task, files and full answers →Statistical reporting contracts
Compute each team mean over known values, then return team,id,value for observations strictly greater than twice that mean. Sort team,id.
Open task, files and full answers →Statistical reporting contracts
For each known observation return team,id,value,at_or_below: the number of known observations in that team <= its value. Ties must share the same cumulative count. Sort team,value,id.
Open task, files and full answers →Cohorts and customer journeys
As of day14, first activity must be on or after signup. Return user_id,signup_day,activation_day for all users; NULL means not yet active. Sort user_id.
Open task, files and full answers →Cohorts and customer journeys
Group activated users by activation_day. Return activation_day,activated_users,returned_next_day; a user counts once if any activity occurs exactly one day after activation, no later than day14. Sort activation_day.
Open task, files and full answers →Cohorts and customer journeys
For every activated user return user_id,activation_day,first_return_day. A same-day second event is not a return; preserve NULL if there is no later-day activity by day14. Sort user_id.
Open task, files and full answers →Cohorts and customer journeys
For valid purchases through day14, group by signup_day and integer week_offset=(purchase_day-signup_day)/7. Return signup_day,week_offset,revenue_cents sorted both. Include only observed purchase cells.
Open task, files and full answers →Cohorts and customer journeys
Deduplicate valid activity to user/day. Return user_id,return_day,previous_day for return days with at least seven intervening inactive days, so return_day-previous_day>7. Sort user_id,return_day.
Open task, files and full answers →Cohorts and customer journeys
For days0 through14 return day,registered_users,purchasers through that day. Users enter the denominator on signup; purchases before signup are excluded. One user counts once. Sort day.
Open task, files and full answers →Cohorts and customer journeys
For users with at least two valid purchase events through day14, order by day then id and return user_id,first_day,second_day,lag_days. Same-day separate purchases would have zero lag. Sort user_id.
Open task, files and full answers →Cohorts and customer journeys
As of day14 only activation_day<=7 has a complete seven-day follow-up. For each matured activation cohort return activation_day,eligible_users,returned_day7. A return must be exactly activation+7. Sort activation_day.
Open task, files and full answers →Cohorts and customer journeys
For every registered user classify first valid purchase as same_day,days_1_6,days_7_plus or not_paid as of14. Return channel,lag_band,users sorted channel,lag_band.
Open task, files and full answers →Cohorts and customer journeys
For each signup cohort with purchases, return signup_day,top_user_id,top_user_revenue,cohort_revenue. Pick the highest total purchaser, ties smaller user_id. Sort signup_day.
Open task, files and full answers →Experiment data quality
Return user_id,variant_count for users assigned to more than one distinct variant. Exact repeats of the same variant do not constitute contamination. Sort user_id.
Open task, files and full answers →Experiment data quality
For each outcome compare its minute with the user earliest assignment. Return outcome_id,user_id,outcome_minute,assignment_minute for outcomes strictly earlier. Sort outcome_id.
Open task, files and full answers →Experiment data quality
Assign every user to their earliest assignment, ties by id; keep contaminated users in their initial arm. A conversion is any positive-value outcome at or after that assignment. Return variant,assigned_users,converted_users sorted variant.
Open task, files and full answers →Experiment data quality
Under a fixed 50/50 design, count each user by first assignment. Return variant,observed_users,expected_users,squared_deviation=(observed-expected)^2/expected rounded4. This diagnostic is not a p-value. Sort variant.
Open task, files and full answers →Experiment data quality
For each first-assigned user return user_id,measurement_status: no_outcome if no eligible event, unexposed if events exist but none exposed=1, exposed_zero if exposed events exist and their value sum=0, otherwise exposed_value. Sort user_id.
Open task, files and full answers →Experiment data quality
Keep the smallest id for identical user_id,variant,minute,device,stratum payloads. Return removed_id,kept_id for exact retransmissions only; conflicting payloads remain. Sort removed_id.
Open task, files and full answers →Experiment data quality
Return variant,device,users from one earliest assignment per user, and device_share_pct within that arm rounded2. Sort variant,device.
Open task, files and full answers →Experiment data quality
For each first-assignment user sum eligible outcome values, zero if absent. Per stratum return stratum,mean_A,mean_B,difference_B_minus_A rounded2. Both arms are present in each supplied stratum. Sort stratum.
Open task, files and full answers →Experiment data quality
Sum valid outcomes per first-assigned user, then cap that user total at100 cents. Include zero-outcome users. Return variant,capped_mean rounded2, sorted variant.
Open task, files and full answers →Experiment data quality
Under first-assignment eligibility, a user fails if any eligible outcome has error=1 OR they were assigned multiple variants. Return user_id,error_flag,contamination_flag for failed users only, sorted user_id.
Open task, files and full answers →Subscription service and billing
The billing month is [0,30). Paid service begins at max(start_day,trial_end), ends at min(end_day,cancel_day if present,30), and is half-open. Return contract_id,paid_days,seat_days,charge_cents sorted contract_id.
Open task, files and full answers →Subscription service and billing
At start of day15, split paid contract charges inside[0,30) into earned days before15 and future days from15. Return contract_id,earned_cents,future_cents sorted contract_id.
Open task, files and full answers →Subscription service and billing
Within[0,30) and before cancellation, count active days and trial days before trial_end. Return contract_id,active_days,trial_days,paid_days; enforce active=trial+paid. Sort contract_id.
Open task, files and full answers →Subscription service and billing
Return usage_id,contract_id,day for usage before paid service begins or at/after its end, using the month[0,30) clipping. Sort usage_id.
Open task, files and full answers →Subscription service and billing
For each contract sum only entitled usage. First100 units cost2 cents each; next100 cost1 cent each; remaining units cost3 cents each. Return contract_id,eligible_units,usage_charge_cents for every contract. Sort contract_id.
Open task, files and full answers →Subscription service and billing
Every contract has a1000-cent monthly minimum commitment against actual paid seat-day charges. Return contract_id,service_cents,trueup_cents,final_cents. A trial-only or short service still has the declared minimum. Sort contract_id.
Open task, files and full answers →Subscription service and billing
Compare prepaid paid service through min(end_day,30) with service ending at cancel_day. Return cancelled contract_id,unused_days,credit_cents; only contracts with cancellation before month-end qualify. Sort contract_id.
Open task, files and full answers →Subscription service and billing
For each entitled integer day in[0,30), check whether any bill for that contract covers the day. Return contract_id,unbilled_days,unbilled_cents including zeros. Sort contract_id.
Open task, files and full answers →Subscription service and billing
For every bill calculate (end_day-start_day)*seats*daily_cents without re-clipping. Return bill_id,billed_cents,contracted_cents,difference_cents=billed-contracted. Sort bill_id.
Open task, files and full answers →Subscription service and billing
For every day0..29 return day,active_contracts,daily_revenue_cents from paid entitled service at that day. Cancellation day itself is excluded. Sort day.
Open task, files and full answers →Stock layers and movement evidence
All supplied issue sequences have no later receipt before an earlier shortage except SKU C with a terminal shortage. Allocate each issue across lots in received,id order, considering cumulative quantities. Return issue_id,lot_id,allocated_units for positive covered quantities only, sorted issue_id,lot_id.
Open task, files and full answers →Stock layers and movement evidence
After all supplied FIFO issues, report lots with positive remaining units and expiry<=20. Return lot_id,sku,remaining_units,expiry sorted expiry,lot_id.
Open task, files and full answers →Stock layers and movement evidence
Return issue_id,covered_units,cogs_cents,uncovered_units. Covered cost is sum allocated units*lot cost. Shortage units have no invented cost. Sort issue_id.
Open task, files and full answers →Stock layers and movement evidence
Interleave receipts before issues on the same day, by id. A receipt adds quantity and acquisition value; an issue consumes up to available quantity at the current average. Return issue_id,moving_unit_cost,covered_units,moving_cogs_cents, money rounded2. Sort issue_id.
Open task, files and full answers →Stock layers and movement evidence
Using FIFO received layers, return issue_id,sku,uncovered_units for issues with any shortage. Preserve only uncovered units, not the whole issue. Sort issue_id.
Open task, files and full answers →Stock layers and movement evidence
Group transfer movements by pair_id. Return pair_id,movement_count,net_units only for pairs with exactly two movements and a nonzero sum. Sort pair_id.
Open task, files and full answers →Stock layers and movement evidence
For transfer pair_ids with one movement, return pair_id,warehouse,missing_side: destination for a negative sole leg, origin for a positive sole leg. Sort pair_id.
Open task, files and full answers →Stock layers and movement evidence
After all issues return sku,remaining_units,remaining_value_cents from unconsumed lot quantities. Include fully depleted SKU with zero. Sort sku.
Open task, files and full answers →Stock layers and movement evidence
A lot is expired when issue_day>=expiry. From FIFO allocation return issue_id,lot_id,expired_units for allocations meeting that condition. Sort issue_id,lot_id.
Open task, files and full answers →Stock layers and movement evidence
Return warehouse,outbound_units,inbound_units,net_units. Outbound is positive magnitude of negative legs; inbound sums positive legs. Retain unpaired legs for operational review. Sort warehouse.
Open task, files and full answers →Access and evidence policies
For every request recursively inherit groups plus public. Consider grants with expires>request day and exact resource. Any applicable deny wins over allows; otherwise allow if one allow exists, else deny. Return request_id,decision sorted request_id.
Open task, files and full answers →Access and evidence policies
For requests list each applicable nonpublic allow grant whose principal is not the requesting user, including transitive groups. Return request_id,grant_id,principal sorted request_id,grant_id.
Open task, files and full answers →Access and evidence policies
Return request_id,expired_grant_id when an exact-resource direct allow to that user exists but expires<=request day. This is an expired-evidence report even if a group separately allows access. Sort both.
Open task, files and full answers →Access and evidence policies
Return approval_id,requester,resource where requester=approver. Another approval by a different person does not erase the violating row. Sort approval_id.
Open task, files and full answers →Access and evidence policies
At day10, return grant_id,principal,resource for direct user allow grants expiring>10 with no same-user/resource request anywhere in the log. Known users are alice,bob,outsider; exclude group/public grants. Sort grant_id.
Open task, files and full answers →Access and evidence policies
At day10 return resource,public_grants,minimum_mask for live public allow grants. This lists exposure surface, not private-user effective permissions. Sort resource.
Open task, files and full answers →Access and evidence policies
For requests with at least one live applicable allow and no live applicable deny, output request_id,mask_level as MAX(mask) across the matching allow grants. Higher numbers are stricter. Sort request_id.
Open task, files and full answers →Access and evidence policies
At day10 an approval is valid only when requester differs from approver, and the approver inherits a live allow for that resource without a matching deny. Return approval_id,approver sorted approval_id. Public permissions also count.
Open task, files and full answers →Access and evidence policies
The local policy permits at most one membership hop. At each request day consider exact-resource unexpired allows and all-depth denies. Return request_id,minimum_allow_depth only when some otherwise valid allow exists, no applicable deny exists, but every allow requires more than one hop. Public or direct allow depth is0. Sort request_id.
Open task, files and full answers →Access and evidence policies
At day0 consider direct user allow grants with expires>0. For each find the first same-principal/resource request on or after day0. Return grant_id,next_request_day,expires if next request is at or after expiry. Sort grant_id.
Open task, files and full answers →Workforce and service coverage
An end earlier than start means next day; equal times mean zero duration. Return shift_id,elapsed_minutes,paid_minutes=elapsed-break. Sort shift_id.
Open task, files and full answers →Workforce and service coverage
Per employee/day return booked_paid_minutes summing shift durations less breaks, and shift_count. Do not silently deduplicate overlapping shifts; this is the payroll claim total for review. Sort employee,day.
Open task, files and full answers →Workforce and service coverage
All shifts are in one payroll week. Order by day,start,id per employee. The first1200 paid minutes are regular; later minutes are overtime. Return shift_id,regular_minutes,overtime_minutes sorted shift_id.
Open task, files and full answers →Workforce and service coverage
Convert shifts to absolute minutes, allowing midnight rollover. Return shift_a,shift_b,overlap_minutes for same-employee pairs a<b with positive overlap. Sort both IDs.
Open task, files and full answers →Workforce and service coverage
Order shifts by absolute start,id within employee. Between each previous shift and current shift calculate rest_minutes, which may be negative. Return employee,previous_id,shift_id,rest_minutes when rest<660. Sort employee,shift_id.
Open task, files and full answers →Workforce and service coverage
For each employee in leave_events, grant adds days, use subtracts, reverse_use restores. Return employee,balance_days,overdrawn as1 if negative else0. Sort employee.
Open task, files and full answers →Workforce and service coverage
For a separate prospective one-hour crew, assign one lead and one desk worker using skills and crew_cost. One employee cannot occupy both simultaneous roles. Ignore historical shifts in this prospective assignment. Return lead_employee,desk_employee,hourly_total_cents for the cheapest pair; tie by lead then desk name.
Open task, files and full answers →Workforce and service coverage
For shift2, candidates must have its required skill, differ from the assigned employee, and have no overlapping absolute-time shift. Return employee sorted.
Open task, files and full answers →Workforce and service coverage
Return day,lead_employees,lead_paid_minutes for shifts whose role is lead. Count unique employees but sum paid minutes. Only supplied lead days appear. Sort day.
Open task, files and full answers →Workforce and service coverage
For every shift choose a different employee same-role shift ending no later than its absolute start, with greatest end then smallest id. Return shift_id,predecessor_id orNULL. Sort shift_id.
Open task, files and full answers →Delivery evidence and route operations
Per order return order_id,delivered_units,required_units,completion_day. Completion day is MAX delivered day only when delivered units meet required_units; otherwiseNULL. Undelivered package units do not count. Sort order_id.
Open task, files and full answers →Delivery evidence and route operations
An order is OTIF only when units delivered by its planned day meet required_units. Return order_id,on_time_units,otif flag sorted order_id. Late units cannot repair this historical metric.
Open task, files and full answers →Delivery evidence and route operations
Pick the first attempt per package by minute,id. Per carrier return packages_attempted,first_successes. Packages without an attempt are excluded from this attempt metric. Sort carrier.
Open task, files and full answers →Delivery evidence and route operations
For each route/stop return route,seq,dwell_minutes,travel_from_previous. The first travel isNULL; later travel is arrival minus previous departure. Sort route,seq.
Open task, files and full answers →Delivery evidence and route operations
Opening load is0. After every stop cumulative load_delta must be between0 and8 inclusive. Return route,seq,load_units for excursions outside that range. Sort route,seq.
Open task, files and full answers →Delivery evidence and route operations
For each route/pair_id return route,pair_id,drop_seq,pickup_seq when the first drop precedes first pickup. Both are present in the sample. Sort route,pair_id.
Open task, files and full answers →Delivery evidence and route operations
Per package whose first attempt failed, find its first later success. Return package_id,first_failed_minute,recovered_minute,recovery_minutes; retain NULL recovery for still-failing packages. Sort package_id.
Open task, files and full answers →Delivery evidence and route operations
A delivered package needs signature or photo; a scan is insufficient. Return package_id,carrier for delivered packages without acceptable proof. Sort package_id.
Open task, files and full answers →Delivery evidence and route operations
For each carrier return delivered_units,late_units and undelivered_units. Late means delivered_day>planned_day; NULL is undelivered rather than late. Sort carrier.
Open task, files and full answers →Delivery evidence and route operations
For each order return order_id,carrier_count,cross_carrier as1 when more than one distinct carrier is involved. Sort order_id. Count the planned package routing regardless of delivery status.
Open task, files and full answers →Data integrity acceptance contracts
Ignore NULL and empty email. Return customer,distinct_emails for customer keys associated with more than one distinct email, irrespective of exact duplicate rows. Sort customer.
Open task, files and full answers →Data integrity acceptance contracts
Return id,declared_total,calculated_total,difference=total-qty*unit_price only when the declared total disagrees. Negative quantities are a separate rule, not a reason to skip arithmetic. Sort id.
Open task, files and full answers →Data integrity acceptance contracts
Return id,country,currency for rows whose pair is absent from country_currency. A known country alone is insufficient. Sort id.
Open task, files and full answers →Data integrity acceptance contracts
Return batch,source_rows,valid_currency_pairs,invalid_currency_pairs using the exact country/currency pair rule, retaining duplicate source rows because this is ingest coverage. Sort batch.
Open task, files and full answers →Data integrity acceptance contracts
Allowed attributes are color,size. Return record_id,issue for unexpected attribute names, plus missing_color for each record appearing in attributes without a color row. UNION both issue types; sort record_id,issue.
Open task, files and full answers →Data integrity acceptance contracts
Priority: deleted→tombstone; qty<0→negative_qty; bad total→bad_total; invalid country/currency→bad_pair; otherwise accepted. Return reason,row_count with reasons actually present, sorted reason.
Open task, files and full answers →Data integrity acceptance contracts
Customer IDs are connected when they share a nonempty email; take transitive closure. Return customer,cluster_id as the lexicographically smallest customer in its connected component. Sort customer.
Open task, files and full answers →Data integrity acceptance contracts
Per batch return batch,null_email,empty_email,present_email. NULL is absent; empty is the zero-length string; all other strings are present. Sort batch.
Open task, files and full answers →Data integrity acceptance contracts
Within each customer choose largest id as the authoritative record, then exclude it if deleted=1. Return customer,source_id,email sorted customer. Do not filter tombstones before ranking.
Open task, files and full answers →Data integrity acceptance contracts
For each record_id in attributes return record_id,color,size,color_rows,size_rows. MIN supplies display text; counts expose duplicate attributes instead of silently treating the pivot as unique. Sort record_id.
Open task, files and full answers →Reliable and fair dispatch queues
For queued jobs rank within tenant by created,id; dispatch by that round number then tenant. Return job_id,tenant,dispatch_position. Sort dispatch_position.
Open task, files and full answers →Reliable and fair dispatch queues
At minute20 effective_score=priority+floor((20-created)/5). Rank queued jobs by score descending, created ascending,id. Return job_id,effective_score,dispatch_position sorted position.
Open task, files and full answers →Reliable and fair dispatch queues
At minute20 a running job counts toward concurrency only if lease_until>20. Tenant cap is1. For tenants with spare capacity pick oldest queued created,id. Return tenant,job_id sorted tenant.
Open task, files and full answers →Reliable and fair dispatch queues
Return queued job_id ready for dispatch only when every dependency job has status done. Jobs with no dependencies are ready. Sort job_id.
Open task, files and full answers →Reliable and fair dispatch queues
At minute20 return job_id,tenant,expired_minutes=20-lease_until for running jobs with lease_until<=20. Do not reclaim done or queued jobs. Sort job_id.
Open task, files and full answers →Reliable and fair dispatch queues
For queued jobs with attempts>0 use delay=2^attempts minutes after last_attempt. Return job_id,next_eligible_minute,ready_at20 flag; calculate powers by recursive doubling rather than unsupported functions. Sort job_id.
Open task, files and full answers →Reliable and fair dispatch queues
At maximum3 attempts, return queued job_id,attempts,disposition as dead_letter when attempts>=3 else retryable. Include only attempted queued jobs. Sort job_id.
Open task, files and full answers →Reliable and fair dispatch queues
Return old_job,new_job for queued pairs where the older created job has lower priority than the newer job. Same created time is not older. Sort both IDs.
Open task, files and full answers →Reliable and fair dispatch queues
Return worker_id,job_id for queued jobs matching the worker skill, with all dependencies done. Do not apply retry/concurrency policies in this capability view. Sort worker_id,job_id.
Open task, files and full answers →Reliable and fair dispatch queues
At20 classify queued wait<10 as recent, otherwise aged. Return tenant,recent_jobs,aged_jobs,total_jobs sorted tenant. Age=20-created.
Open task, files and full answers →Versioned facts and temporal truth
For each entity select versions valid at day5 and recorded<=9; latest recorded then id wins. Exclude a selected tombstone. Return entity,version_id,value sorted entity.
Open task, files and full answers →Versioned facts and temporal truth
For each fact compare the latest valid version as known at cutoff9 with cutoff15. Return fact_id,old_value,new_value only when their selected values differ, including tombstone deletion asNULL. Sort fact_id.
Open task, files and full answers →Versioned facts and temporal truth
At cutoff15 count all nondeleted valid version matches before precedence. Return fact_id,matching_versions only when count>1. Sort fact_id.
Open task, files and full answers →Versioned facts and temporal truth
For integer days0..19 and entities in versions, at cutoff7 find those with no version recorded<=7 covering that day. Return entity,missing_day sorted both. Deleted records are still coverage evidence for this structural check.
Open task, files and full answers →Versioned facts and temporal truth
At cutoff15 choose latest recorded valid version for each fact. Return fact_id,tombstone_id only when that selected version is deleted=1. Sort fact_id.
Open task, files and full answers →Versioned facts and temporal truth
Return version_id,entity,backdated_days=recorded-valid_from for versions recorded after valid_from. Keep original and correction records, sort backdated_days descending then version_id.
Open task, files and full answers →Versioned facts and temporal truth
At cutoff15 choose latest recorded valid version per fact, suppress tombstones and retain unmatched facts asNULL unit_value and extended_value. Return fact_id,unit_value,extended_value=amount*value sorted fact_id.
Open task, files and full answers →Versioned facts and temporal truth
For each version return version_id,previous_version_id: latest earlier recorded version of the same entity and identical valid_from/valid_to. Use recorded,id ordering andNULL when none. Sort version_id.
Open task, files and full answers →Versioned facts and temporal truth
At cutoff15, return version_a,version_b,overlap_days for nondeleted same-entity versions a<b with positive overlap, excluding pairs with identical validity endpoints because those are corrections. Sort both IDs.
Open task, files and full answers →Versioned facts and temporal truth
Compare selected nondeleted version ids at recorded cutoffs7 and15 for every fact. Return drift_status,affected_facts where status is stable,backfilled,removed,revised; use id changes as revision even if values match. Sort status.
Open task, files and full answers →Procurement tradeoffs and award evidence
A kit needs6A and3B. Every supplier must cover both SKU quantities within capacity and MOQ. Charge the supplier maximum quoted shipping once. Return supplier,goods_cents,freight_cents,total_cents sorted total,supplier.
Open task, files and full answers →Procurement tradeoffs and award evidence
For A quantity6 first require MOQ<=6<=capacity. Total cost=6*unit+shipping. A bid is dominated if another feasible bid costs no more and takes no longer, with at least one strict improvement. Return bid_id,supplier,total_cents,lead_days for all nondominated alternatives, sorted bid_id. Do not impose a deadline or collapse to one cheapest winner.
Open task, files and full answers →Procurement tradeoffs and award evidence
For A demand20, ignore MOQ and fixed freight for this explicitly divisible allocation. Order bids by unit_cents,id; allocate up to capacity until20 filled. Return bid_id,award_units,goods_cents for positive awards sorted bid_id.
Open task, files and full answers →Procurement tradeoffs and award evidence
For quantity6 of A, consider bids with capacity>=6 and MOQ<=6. Cost bounds are6*unit+shipping+risk_low/high. Return dominated_bid,dominating_bid when another bid worst-case is strictly below its best-case. Sort both IDs.
Open task, files and full answers →Procurement tradeoffs and award evidence
Supply A quantity10 using Alpha and Beta. Each supplier may receive zero or an integer quantity between MOQ and capacity. Pay its shipping only if used. Enumerate all splits; return alpha_units,beta_units,total_cents for minimum cost, ties fewer Alpha units.
Open task, files and full answers →Procurement tradeoffs and award evidence
Approval day8 and delivery deadline14. For each A bid return bid_id,expiry_slack=expires-8,delivery_slack=14-8-lead_days,limiting_slack=min. Negative means already infeasible. Sort bid_id.
Open task, files and full answers →Procurement tradeoffs and award evidence
Return line,old_value,new_value,delta_value,change_type from amendments. Type is added if old_units=0, cancelled if new_units=0, otherwise increased/decreased/unchanged by quantity. Sort line.
Open task, files and full answers →Procurement tradeoffs and award evidence
For kit quantities, choose each SKU lowest unit price ignoring capacity/MOQ, tie bid id. Report one row split_goods_cents,split_freight_cents using each winning supplier freight once,total_cents.
Open task, files and full answers →Procurement tradeoffs and award evidence
Buyer permits orders between4 and9 units. Intersect each A bid MOQ/capacity interval with that buyer range. Return bid_id,min_usable,max_usable only when intersection nonempty. Sort bid_id.
Open task, files and full answers →Procurement tradeoffs and award evidence
For suppliers able to supply each kit line within MOQ/capacity, return supplier,base_total,risk_reserve,worst_case_total. Freight charged once; reserve is MAX risk_high once per supplier, not per line. Sort supplier.
Open task, files and full answers →Cash allocation and financial controls
At day9 sum customer cash including signed reversals. Apply it to invoices in due,id order, never more than invoice cents. Return invoice_id,applied_cents,remaining_cents. Sort invoice_id.
Open task, files and full answers →Cash allocation and financial controls
At day9 for every customer present in invoices or cash, return customer,invoice_cents,net_cash_cents,unapplied_credit=max(0,cash-invoice),unpaid=max(0,invoice-cash). Sort customer.
Open task, files and full answers →Cash allocation and financial controls
For each original positive cash record original_id IS NULL, return original_id,gross_cents,reversed_cents,net_cents. Reversed cents is positive magnitude of linked negative rows; do not match by customer alone. Sort original_id.
Open task, files and full answers →Cash allocation and financial controls
Return first_id,second_id,customer,day,cents for positive original capture pairs a<b with same customer/day/cents. This is a review queue, not proof that either row is invalid. Sort IDs.
Open task, files and full answers →Cash allocation and financial controls
Return cash_id,customer,cents for cash records whose customer has no invoice at all. Keep the cash evidence rather than dropping it in an inner join. Sort cash_id.
Open task, files and full answers →Cash allocation and financial controls
For every invoice divide into3 integer-cent installments: first two use floor(cents/3), final installment receives the residual. Return invoice_id,installment,amount_cents ordered both.
Open task, files and full answers →Cash allocation and financial controls
Per contract return contract,required_count,approved_required,release_cents. Release all milestone cents only if every required milestone is approved; zero required milestones satisfies the condition. Sort contract.
Open task, files and full answers →Cash allocation and financial controls
Reserve40% of each invoice unpaid after customer-wide day9 cash waterfall, capped at100 cents per invoice. Output invoice_id,unpaid_cents,reserve_cents for positive unpaid only. Use integer division to floor. Sort invoice_id.
Open task, files and full answers →Cash allocation and financial controls
Positive original captures each incur2.5% rounded to nearest cent half-up plus30 cents. Reversals do not refund fees under this exercise policy. Per customer return customer,captures,per_capture_fee,aggregate_fee,rounding_difference. Aggregate fee rounds2.5% of summed captures once plus30 per capture. Sort customer.
Open task, files and full answers →Cash allocation and financial controls
At day9 return one row invoice_total,net_cash,total_unpaid,total_credit. Reconcile invoice_total-net_cash=total_unpaid-total_credit across the union of customers.
Open task, files and full answers →Business calendars and period reporting
For every case choose the third business date strictly after opened, from supplied calendar. Business dates exclude weekends and holiday=1. Return case_id,deadline orNULL if calendar insufficient. Sort case_id.
Open task, files and full answers →Business calendars and period reporting
For every supplied calendar day return day,revenue_cents,source_rows. No activity has sum0 and source_rows0; an actual zero event has source_rows1. Sort day.
Open task, files and full answers →Business calendars and period reporting
Classify every supplied calendar date as holiday first, then weekend, otherwise business. Return day_type,calendar_days,revenue_cents aggregated after daily pre-summing. Sort day_type.
Open task, files and full answers →Business calendars and period reporting
Aggregate events per calendar day, then compute running revenue within strftime %Y-%W week. Return day,week_key,week_running_cents for all calendar dates sorted day.
Open task, files and full answers →Business calendars and period reporting
For each calendar day average dense daily revenue over current and two previous supplied dates, using fewer dates at start, rounded2. Return day,three_day_mean sorted day.
Open task, files and full answers →Business calendars and period reporting
Return day for calendar dates with no daily row. A real zero event counts as present. Sort day.
Open task, files and full answers →Business calendars and period reporting
Fiscal year starts April1 and is named by its starting calendar year. For every date return day,fiscal_year,fiscal_quarter. Sort day.
Open task, files and full answers →Business calendars and period reporting
For each case birthday, calculate its2027 anniversary. February29 maps to February28; other month/day values stay unchanged. Return case_id,anniversary sorted case_id.
Open task, files and full answers →Business calendars and period reporting
Return one row first_business,last_business,business_days from the supplied calendar, excluding holidays and weekends. Do not assume the first calendar day is open.
Open task, files and full answers →Business calendars and period reporting
At2026-11-15 count business dates strictly after opened and on or before cutoff. Return case_id,business_age_days sorted case_id.
Open task, files and full answers →Sets multiplicity and evidence
Return entity_a,entity_b for pairs a<b whose DISTINCT feature sets are identical. Extra features disqualify equality. Sort both.
Open task, files and full answers →Sets multiplicity and evidence
Compare feed one against two by key multiplicity. Return key,excess_copies=max(0,count_one-count_two), positive only, sorted key.
Open task, files and full answers →Sets multiplicity and evidence
Across feeds one and two return key,side for keys present in exactly one feed. Duplicate copies do not change membership. Sort key.
Open task, files and full answers →Sets multiplicity and evidence
Return smaller_entity,larger_entity when the first DISTINCT feature set is a proper subset of the second. Equal sets do not qualify. Sort both entities.
Open task, files and full answers →Sets multiplicity and evidence
Return entity_a,entity_b for distinct entity pairs a<b with empty feature intersection. Sort both.
Open task, files and full answers →Sets multiplicity and evidence
Return key present in one,two and three at least once. Use set intersection, sorted key. Duplicates in one feed cannot substitute for a missing feed.
Open task, files and full answers →Sets multiplicity and evidence
Return claim,source_count,independent_owners for claims with at least2 distinct owner IDs. Several sources owned by the same organization count as one independent owner. Sort claim.
Open task, files and full answers →Sets multiplicity and evidence
For every feature return feature,raw_rows,adopting_entities,duplicate_rows=raw-distinct entities. Sort feature.
Open task, files and full answers →Sets multiplicity and evidence
For each key in any feed and each named feed, output key,missing_feed when the key has no row in that feed. Sort key,missing_feed.
Open task, files and full answers →Sets multiplicity and evidence
For every feed pair a<b return feed_a,feed_b,difference_copies as the sum of absolute per-key count differences across their key union. Include zero for exact multiset matches. Sort pair.
Open task, files and full answers →Explainable business reporting
For SKUs present in both periods aggregate units and use their single supplied price per period. Volume effect=(q2-q1)*p1; price effect=q2*(p2-p1). Return sku,volume_effect,price_effect,revenue_change; sort sku. Exclude new SKU D from comparable decomposition.
Open task, files and full answers →Explainable business reporting
For period2 rank SKUs by gross revenue descending, ties sku. Include rows while prior cumulative revenue<80% of total, including the row crossing80%. Return sku,revenue_cents,cumulative_cents sorted rank.
Open task, files and full answers →Explainable business reporting
For period2 output row_type,channel,sku,revenue_cents for detail channel/SKU, channel subtotal withNULL sku, grand total with bothNULL. Sort row_type,channel,sku; row types are1_detail,2_channel,3_total.
Open task, files and full answers →Explainable business reporting
For each user require a visit, then cart strictly later than first visit, then buy strictly later than that first eligible cart. Return user,visited,carted,converted flags sorted user. Earlier or same-time buys do not qualify.
Open task, files and full answers →Explainable business reporting
Choose minimum minute per customer; ties choose channel alphabetically. Return customer,first_channel,first_minute sorted customer. Do not choose the last touch.
Open task, files and full answers →Explainable business reporting
Per period/sku assume returned units refund both revenue and cost at the supplied per-unit amounts. Return period,sku,net_units,net_revenue,net_cost,margin_cents sorted period,sku.
Open task, files and full answers →Explainable business reporting
For each SKU in either period compute unit share_pct per period over that period total units, missing SKU share0; return sku,share1_pct,share2_pct,change_points rounded2, sort sku.
Open task, files and full answers →Explainable business reporting
For period2, a SKU fails if (price-cost)*100<20*price before returns. Return sku,gross_revenue,margin_pct rounded2 for failures sorted revenue descending,sku.
Open task, files and full answers →Explainable business reporting
Classify each SKU as new if only period2, discontinued if only period1, otherwise comparable. Return status,revenue1,revenue2,change_cents grouped status sorted status.
Open task, files and full answers →Explainable business reporting
For each channel across both periods return channel,sold_units,returned_units,return_pct=100*returned/sold rounded2. Do not divide by remaining net units. Sort channel.
Open task, files and full answers →