A report of item revenue by payment method adds up to more than the whole of order_items. It joins order_items to payments on order_id, and an order can have several rows in each of those tables.
Return payment_method, paid_orders (orders whose payment with payment_status succeeded used that method), item_revenue (the sum of line_total for those orders), joined_revenue (what the report's join returns: line_total summed over every pair of an item row and a payment row with the same order_id), and overstated_by (joined_revenue minus item_revenue), with the three amounts rounded to 2 decimals. An order's items belong to the method of its succeeded payment, and orders with no succeeded payment are left out of paid_orders and item_revenue. Order by payment_method.
Create a free account to save your progress and reveal the worked answer for this free exercise. The complete practice library is available with Practice Pass or Mastery.