SQL left join: run on your own data

Keep every row from the left input and attach its region total from the right query. An unmatched right row would produce null columns.

Updated

Synthetic worked example · 4 input rows
SELECT a.Label, b.total FROM input a LEFT JOIN (SELECT Region, sum(Amount) AS total FROM input GROUP BY Region) b ON a.Region = b.Region ORDER BY a.Period

What does this formula return?

Loading the browser engine to calculate this sample…

Edit the sample rowsClick any value · changes recalculate

Empty numeric cells are null. Every input row is used in the calculation.

Use your own CSV
Run it on my CSV

Drop one CSV anywhere. It is calculated in this browser; nothing is uploaded.

Nothing is uploaded.

Original worked examples, sources and questions

The recorded examples below retain their original source rows. The live result above uses the current rows and formula.

SQL left join: run on your own data

Keep every row from the left input and attach its region total from the right query. An unmatched right row would produce null columns.

How does this worked example calculate its result?

SELECT a.Label, b.total FROM input a LEFT JOIN (SELECT Region, sum(Amount) AS total FROM input GROUP BY Region) b ON a.Region = b.Region ORDER BY a.Period

DuckDB SQL reads these rows from the table input. SQL dialects differ; this page runs the syntax shown here.

Which sample rows are used in this example?

RegionAmountLabelPeriod
North10North-one1
North20North-two2
SouthnullSouth-one3
South5South-two4

What result should the sample formula return?

column 1column 2
North-one30
North-two30
South-one5
South-two5

Replace the rows or formula in the playground. The live result is computed from the current inputs; the worked example above stays as a reference.

Which SQL examples can I run next?

What does the sql left join worked example calculate?

Keep every row from the left input and attach its region total from the right query. An unmatched right row would produce null columns.

Updated

What formula and inputs define this worked example?

This worked example uses 4 explicitly supplied input rows and their stated field types. Published inputs, field types and recorded results (JSON) identify the exact example.

The formula for this published example is:

SELECT a.Label, b.total FROM input a LEFT JOIN (SELECT Region, sum(Amount) AS total FROM input GROUP BY Region) b ON a.Region = b.Region ORDER BY a.Period

DuckDB SQL function documentation provides the language reference. The linked JSON supplies the concrete input and output for this page.

What recorded result comes from this exact sample formula?

For the formula SELECT a.Label, b.total FROM input a LEFT JOIN (SELECT Region, sum(Amount) AS total FROM input GROUP BY Region) b ON a.Region = b.Region ORDER BY a.Period, the published 4-row input has 4 recorded result rows. These are xmetric sample-example results; they do not establish native Tableau or Power BI parity, workbook coverage or corpus-wide compatibility.

column 1column 2
North-one30
North-two30
South-one5
South-two5

How can I run this example on my own CSV?

Choose or drop one CSV into the live panel, match fields when the Tableau view requires mappings, and use the raw column names or mapped calculation names in that Tableau formula. Mapped names take precedence if names differ only in capitalization or collide. SQL and DAX use your actual column names. Choose Row calculation to write a new Tableau formula on the raw columns. Opening a CSV alone does not calculate a result; select Run formulas to evaluate the current rows. The panel is a progressive enhancement of the formula and recorded example already present in this HTML.

How do Tableau, DuckDB SQL and scalar DAX differ in this example?

Tableau formulas use the shown field types and view settings. DuckDB SQL reads a table named input; xmetric’s Power BI scalar DAX evaluator reads one table named Sales. Each formula runs independently, so successful execution alone does not establish equivalence.

LanguageFormula supplied on this pageExecution and limitation
TableauNo TABLEAU translation is supplied for this page.xmetric’s Tableau calculation and view services use the supplied rows. LOD view grain and table-calculation addressing or partitioning affect results; a CSV does not import hidden workbook calculations.
DuckDB SQLSELECT a.Label, b.total FROM input a LEFT JOIN (SELECT Region, sum(Amount) AS total FROM input GROUP BY Region) b ON a.Region = b.Region ORDER BY a.PeriodDuckDB compiled to WebAssembly executes the entered query over input. Snowflake, BigQuery and other dialects are not executed by this editor.
xmetric Power BI scalar DAXNo scalar DAX measure is supplied for this page.xmetric evaluates one scalar measure over Sales. A CSV does not supply relationships, hidden measures or a multi-table Power BI model.

What else do people ask?

Can xmetric chart this CSV?

This page’s panel returns formula-result rows. Open the xmetric browser app to create a chart from your CSV. The calculation shown here is SELECT a.Label, b.total FROM input a LEFT JOIN (SELECT Region, sum(Amount) AS total FROM input GROUP BY Region) b ON a.Region = b.Region ORDER BY a.Period; choose dimensions and measures for the question you want to answer.

Does this browser run SQL Server, Snowflake or BigQuery syntax?

This editor runs DuckDB SQL over the table input. SQL dialects differ, so syntax written for SQL Server, Snowflake or BigQuery may need changes. The published query and linked result rows specify the syntax checked on this page.