• Products
  • Documentation
  • Resources

Merge queries

What if your chart needs data from multiple data sources or from tables with no foreign key relations? You can add another query to your Visual SQL, which lets you pull data from a different data source or unrelated table.

Once you’ve built and run your second query, you’ll need to merge the queries together with a “Join” step, blending them into a single result set for your chart. Atlassian Analytics makes it fast and easy to merge the result sets of disparate data sources, allowing for powerful post-processing and calculations. Give it a try and add as many queries as you’d like to your Visual SQL!

Add another query

After executing your initial query, you can add a new query or clone an existing one to your Visual SQL by selecting Add query above the result table. Keep in mind, you can add the new query anywhere in your Visual SQL—just first select the step you’d like the new query to merge with before you add the new query.

Added the query to the wrong place in your Visual SQL? You can either use Undo () to go back to the previous state or drag and drop it to the correct location.

Depending on the type of join you have in mind, you may want to consider having a related (or common) column to join your queries on. A common column refers to a column in each result set containing similar values. For example, if two queries share a date column, merging the queries will combine records with matching dates, resulting in a more insightful output.

Transform your query

After you’ve built and executed (in other words, selected Run query) the new query, you can transform its result set with other Visual SQL steps before you join it with the other result set. View all the available Visual SQL steps.

View your merge results

When you add a new query to Visual SQL, this also adds a “Join” step after your new query (and any transformations you’ve applied to it). Your new query’s result set is automatically merged with the result set of the immediately preceding step (query or otherwise). To see the results of the merge, select the “Join” step in your Visual SQL.

By default, the result sets merge by an outer join on the first columns on the left, but you can change the join type and the number of columns to join on by editing the “Join” step in your Visual SQL.

Use the “Reorder columns” step to move columns in your result set.

Choose your join type

As mentioned above, you can change the join type of your merge. When you merge, the left table’s data is joined with the right table’s data. Think of the top result set as the left table and the nested result set (in other words, the new query’s result set) as the right table. This may help you choose your join type.

Each join type may have other fields you can change to customize your merge. Learn more about the “Join” step.


Additional Help