Orders contain tenant_id and order_id; order_id is unique only within a tenant. Lines contain the same keys. Joining on order_id alone doubles some totals. What is the best correction?

Published
  1. Replace the INNER JOIN with a LEFT JOIN on order_id alone
  2. Add DISTINCT to the final amount column
  3. Join on both tenant_id and order_id before aggregating
  4. Increase the SQL warehouse size before rerunning

Comments — 0