SQL guide

Join two spreadsheets with SQL

Use a join when one worksheet has the amounts and another has the customer names. A reliable join starts with a stable key that means the same thing in both sources.

  1. Register both sources

    Open each workbook or file and identify the aliases shown in Workspace. Test both tables with a small SELECT.

  2. Check your join key

    Confirm that IDs have compatible types and consistent spacing. On the lookup side, group by the key and use HAVING COUNT(*) > 1 to find duplicates that could multiply the result.

  3. Choose how to handle missing records

    An INNER JOIN keeps matches. A LEFT JOIN retains all orders, so missing customer records can be reviewed before export.

Example query

SELECT o.order_id, c.name, o.total
FROM orders o
LEFT JOIN customers c
  ON o.customer_id = c.customer_id
ORDER BY o.order_id;

Check the row count before and after the join. Unexpected growth often points to repeated lookup keys.