---
title: "Gateway - How do I use multiple data sources in gateway SQL"
description: "Using multiple data sources in Gateway SQL involves combining dataviews with the Xpath table as the source. The process includes setting up Xpath, defining columns, querying the source table, and optionally filtering results in the SQL query."
url: "https://docs.itrsgroup.com/docs/faq/geneos/115004028449-geneos-gateway-how-do-i-use-multiple-data-sources-in-gateway-sql/index.html"
---
Use the xpath as source table.

![CPU xpath](https://docscdn.itrsgroup.com/faq/images/geneos/cpu-xpath-table.png)

If you have multiple sources (dataviews) for gateway sql and want to combine them into a single dataview via gateway SQL, you can use the Xpath table. For example, you have 2 CPU samplers belonging to 2 different Managed entities and you want to display the percentUtilisation column only of these 2 samplers in gateway SQL dataview.

Here are the steps:

In this example, my gateway name is `GATEWAY\_9370`, you will need to change this xpath to match your gateway name.

1. Setup the Xpath.

```
/geneos/gateway[(@name="GATEWAY\_9370")]/directory/probe/managedEntity/sampler[(@name="CPU")][(@type="")]/dataview[(@name="CPU")]/rows/row/cell[(@column="percentUtilisation")]
```

This will evaluate to 2 CPU samplers. In my example, my mananged entities are named `LAWIN` and `LAWIN32`.

2. Define the columns you need. For this example, we define the Managed entity name, rowname, and perecntUtilisation.

![CPU xpath columns](https://docscdn.itrsgroup.com/faq/images/geneos/cpu-xpath-defined-columns.png)

3. Query from the source table CPU.

![CPU query](https://docscdn.itrsgroup.com/faq/images/geneos/cpu-query-source-table.png)

4. Resulting dataview will be the following:

![CPU dataview](https://docscdn.itrsgroup.com/faq/images/geneos/cpu-dataview-source-table.png)

5. If you want to show the values from LAWIN managed entity only, then you can filter using sql query:

```
select * from CPU where "ME Name" = 'LAWIN'
```

The result will be the following:

![CPU dataview of LAWIN managed entity](https://docscdn.itrsgroup.com/faq/images/geneos/cpu-lawin-dataview.png)


**Note**



If the resulting dataview have duplicate rows, tick on the **Show row id** option. If the column name have spaces and you want to use it in a query, use double quotes (`""`).




Refer to the XML used:

```
<sampler name="Gateway SQL Example">
   <plugin>
       <Gateway-sql>
           <tables>
               <xpath>
                   <tableName>
                       <data>CPU</data>
                   </tableName>
                   <xpaths>
                       <xpath>/geneos/gateway[(@name=&quot;GATEWAY_9370&quot;)]/directory/probe/managedEntity[contains(@name,&quot;LAWIN&quot;)]/sampler[(@name=&quot;CPU&quot;)][(@type=&quot;&quot;)]/dataview[(@name=&quot;CPU&quot;)]/rows/row/cell[(@column=&quot;percentUtilisation&quot;)]</xpath>
                   </xpaths>
                   <columns>
                       <column>
                           <name>
                               <data>ME Name</data>
                           </name>
                           <xpath>ancestor-or-self::managedEntity/@name</xpath>
                       </column>
                       <column>
                           <name>
                               <data>CPU</data>
                           </name>
                           <xpath>@rowname</xpath>
                       </column>
                       <column>
                           <name>
                               <data>% util</data>
                           </name>
                           <xpath>@value</xpath>
                       </column>
                   </columns>
               </xpath>
           </tables>
           <views>
               <view>
                   <name>
                       <data>Combined CPU</data>
                   </name>
                   <sql>
                       <data>select * from CPU</data>
                   </sql>
                   <showRowID>true</showRowID>
               </view>
           </views>
       </Gateway-sql>
   </plugin>
</sampler>
```

For more information, see [Gateway SQL Reference Guide](https://docs.itrsgroup.com/docs/geneos/current/processing/configuration/geneos_gateway_plugins_tr/index.html#gateway-sql).


