---
title: "Using the SQL macro with Markup - 9.x and earlier"
canonical: "https://support.appfire.com/space/SUPPORT/89137701/Using%20the%20SQL%20macro%20with%20Markup%20-%209.x%20and%20earlier"
format: markdown
---
# <span style="color: #000000">Scenario</span>

> Macro (div)
> 
> > Macro (inline-media-image)
> 
>  <span style="color: #999999">Estimated Time: 8</span>**<span style="color: #999999"> min</span>**<span style="color: #999999"> </span>

<span style="color: #000000">In this scenario, let's insert the </span>*<span style="color: #000000">SQL</span>*<span style="color: #000000"> macro on a Confluence page by inserting</span> [Markup](https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html) <span style="color: #000000">from the menu. The </span>*<span style="color: #000000">SQL</span>*<span style="color: #000000"> macro uses the SQL statement loaded into the body of the macro.</span>

## Background

<span style="color: #000000">This scenario uses a</span> <span style="color: #000000">data source profile,</span><span style="color: #000000"> </span>*<span style="color: #000000">BookWarehouse,</span>*<span style="color: #000000"> to query a database table, </span>*<span style="color: #000000">PUBLISHERS</span>*<span style="color: #000000">. The table contains the following columns and rows:</span>

```sql
SQL > select * from publishers;
+----+------+-------------------+-----------------+---------+
| id | rank | parent_company    | company_name    | revenue |
+----+------+-------------------+-----------------+---------+
| 10 | 1    | Pearson           | Pearson         | 5000.00 |
| 11 | 2    | Reed              | RELXGroup       | 4900.00 |
| 12 | 3    | WoodbridgeCompany | ThompsonReuters | 4700.00 |
| 13 | 4    | BertelsmannAG-NV  | Bertelsmann     | 4500.00 |
| 14 | 5    | WoltersKluwer     | WoltersKluwer   | 4100.00 |
+----+------+-------------------+-----------------+---------+
```

> ℹ️ <span style="color: #000000">For information about data source profiles, refer to:</span>
> ℹ️ 
> ℹ️ - [Data source profiles](https://appfire.atlassian.net/wiki/spaces/SQL/pages/74323164/Configure+Data+Source+Profiles+-+9.x) <span style="color: #000000">for 9.x versions</span>
> ℹ️ - [Data source profiles](https://appfire.atlassian.net/wiki/x/6xNuB) <span style="color: #000000">for 8.x versions</span>

<span style="color: #000000">The sample query against the PUBLISHERS table looks like:</span>

```sql
 SELECT rank as "Worldwide Ranking", company_name as "Company", format(revenue,0) as "M Revenue" FROM publishers ORDER BY rank asc;
```

## <span style="color: #000000">Steps</span>

<span style="color: #000000">The following steps demonstrates how to use Markup to insert the </span>*<span style="color: #000000">SQL</span>*<span style="color: #000000"> macro on a Confluence page:</span>

> Macro (table-plus)
> 
> |  |  |  |
> | --- | --- | --- |
> | ![image](media://ea3d6fa5-ccb3-4693-b922-97b7b1bc71b6) | ## <span style="color: #000000">Create Confluence page</span><br><span style="color: #000000">Create a Confluence page to add the </span>*<span style="color: #000000">SQL</span>*<span style="color: #000000"> macro needed to list out top publishers.</span><br>1. <span style="color: #000000">Create a page named </span>*<span style="color: #000000">Top Publishers Worldwide</span>*<span style="color: #000000"> in a space accessible to the desired audience.</span>
> 2. <span style="color: #000000">Click </span>**<span style="color: #000000">Save</span>**<span style="color: #000000"> to save the new page.</span> |  |
> | --- |
> | ![image](media://a33e0c30-712f-4570-afeb-b76a5bc901fd) | ## <span style="color: #000000">Insert the SQL macro using the Insert Markup Menu</span><br><span style="color: #000000">Edit the </span>*<span style="color: #000000">Top Publishers Worldwide</span>*<span style="color: #000000"> page and:</span><br>1. <span style="color: #000000">Select </span>**<span style="color: #000000">Markup</span>**<span style="color: #000000"> from the top menu.</span>
> 2. <span style="color: #000000">Type the following into the editor window: (Note the data source name referenced)</span>
> 3. <span style="color: #000000">Click </span>**<span style="color: #000000">Insert</span>**<span style="color: #000000"> to insert your Markup within the page.</span>
> 4. <span style="color: #000000">Click </span>**<span style="color: #000000">Save </span>**<span style="color: #000000">to save your page and view your results.</span><br>## <span style="color: #000000">Alternative:</span><br>> Macro (nested-table) | **<span style="color: #000000">How to insert Markup from the menu</span>**<br>![image](media://9dccaaa5-f3c1-4bac-b891-34f618b89de0)<br><span style="color: #000000">**Alternate method:**</span><br>![image](media://9d3fb3b7-e087-49f4-b1ee-cc5015e1364a) |

## <span style="color: #000000">Explore Tutorials</span>

<span style="color: #000000">We've prepared a number of </span>[<span style="color: #000000">tutorials</span>](https://appfire.atlassian.net/wiki/spaces/SQL/pages/74322767/Tutorials)<span style="color: #000000"> which demonstrate how to use our </span>*<span style="color: #000000">SQL</span>*<span style="color: #000000"> macros with the native </span>*<span style="color: #000000">Chart</span>*<span style="color: #000000"> macro.</span>