---
title: "Using the SQL Macro with Markup"
canonical: "https://support.appfire.com/space/SQL/74318357/Using%20the%20SQL%20Macro%20with%20Markup"
format: markdown
---
> Macro (aura-html)

# Scenario

> 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>

In this scenario, we will insert the SQL Macro on a Confluence page by inserting [Markup](https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html) from the menu. Our SQL Macro will reference the SQL statement loaded into the body of the Macro.

## Background

Our scenario will use a [Data Source Profile](https://appfire.atlassian.net/wiki/spaces/SQL/pages/74323164) called "*BookWarehouse*" to query a database table called "PUBLISHERS". The table contains the following columns and rows:

```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 |
+----+------+-------------------+-----------------+---------+
```

Our example query against the PUBLISHERS table looks like:

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

## Steps

The following steps will demonstrate how to use Markup to insert the SQL Macro on a Confluence page.

> Macro (table-plus)
> 
> |  |  |  |
> | --- | --- | --- |
> | ![image](media://f557d35f-b77d-4d62-a9e1-f5330cf82b72) | ## Create Confluence page<br>Create a Confluence page that will eventually contain the SQL Macro needed to list out top publishers.<br>1. Create a page named **Top Publishers Worldwide** in a space accessible to the desired audience.
> 2. Click **Save** to save the new page. |  |
> | --- |
> | ![image](media://bb34d9ef-15de-4dc7-850d-2516dbaf76f1) | ## Insert the SQL Macro using the Insert Markup Menu<br>Edit the **Top Publishers Worldwide** page and:<br>1. Select Insert Markup from the top menu.
> 2. Type the follwing into the editor window. Note the dataSource name  referenced.
> 3. Click Insert to insert your Markup within the page.
> 4. Click **Save **to save your page and view your results.<br>## Alternative:<br>> Macro (nested-table) | **How to insert Markup from the menu**<br>![image](media://82b24433-2a53-43b1-851d-6a69da8e8a54)<br>![image](media://7b2cd6a0-4c7e-4dfa-8b64-dc19a5df03a2) |


## Explore Tutorials

We've prepared a number of tutorials which demonstrate how to use our SQL Macros with the native Chart Macro.

![image](media://9a198717-bb0d-4bd3-97a1-b95bc960d74f)