DataLane

25. Hours from order to settlement

hardProNot started~18 minJoinsTime seriesAggregation

Asked in screens shaped like: Stripe, Adyen, PayPal

Treasury wants average hours between ordered_at and paid_at, by payment method. One payment row per paid order in this warehouse. Return method and avg_hours rounded to 2 decimals, slowest method first.

Requirements

  • Columns: method, avg_hours
  • avg_hours is ROUND(AVG(hours from ordered_at to paid_at), 2)
  • Join payments to orders on order_id
  • Order by avg_hours descending, then method

Expected output

method, avg_hours

Row order is graded, so ORDER BY matters here.

SQL editor

Loading SQL engine…

Ctrl/Cmd + Enter submits

Run your query to see the result set.

Pro problem

Hard problems unlock with Pro

Easy pads stay free. Medium and hard SQL and Python problems — editor, tests, hints, and solutions — open after you upgrade to Pro or coaching.

See plansPractice free easy problems
↑↓ navigate openesc close