07B
Compare these references after your own attempt. You can read them at any time; they do not record a live model or vendor run.
Compare these references after your own attempt. You can read them at any time; they do not record a live model or vendor run.
-- 07b: Reconcile one order safely
SELECT i.order_id,i.line_sales,p.paid_amount FROM (
SELECT order_id,SUM(quantity*unit_price-line_discount) AS line_sales
FROM aabha_sql.order_items WHERE order_id=1006 GROUP BY order_id
) AS i JOIN (
SELECT order_id,SUM(amount) AS paid_amount FROM aabha_sql.payments
WHERE order_id=1006 AND status='succeeded' GROUP BY order_id
) AS p ON p.order_id=i.order_id;