---
title: "Gateway SQL – Example Use case to extract last line of a dataview"
description: "Gateway SQL can extract the last row from a DataView that continuously appends new rows. This is done by creating a new DataView using Gateway-SQL with SQL parameters to select the maximum rowID value."
url: "https://docs.itrsgroup.com/docs/faq/geneos/14673275408541-geneos-gateway-sql-example-use-case-to-extract-last-line-of-a-dataview/index.html"
---
## Related to

GatewaySQL, How to extract value from new updated rows on a dataview

### Problem

*How can I extract the last row from a DataView that keeps appending new rows?*

### Solution

You can extract the last row of your Dataview by using the Gateway-SQL plug-in to create a new, separate view.

Using this toolkit as an example:

![Geneos – Gateway SQL – Example Use case to extract last line of a dataview.](https://docscdn.itrsgroup.com/faq/images/geneos/14673275408541-33980474923805-image.png)

We'll utilize the id(rowID) to extract the maximum value found and display it as a different dataview.

To do this, go to your Gateway-SQL and add the XPATH of the dataview you want to extract

![Geneos – Gateway SQL – Example Use case to extract last line of a dataview.](https://docscdn.itrsgroup.com/faq/images/geneos/14673275408541-33980474927389-image.png)

Name your new data view and add the needed SQL parameters:

![Geneos – Gateway SQL – Example Use case to extract last line of a dataview.](https://docscdn.itrsgroup.com/faq/images/geneos/14673275408541-33980412929949-image.png)

Once applied, you should then see this on your dataview:

![Geneos – Gateway SQL – Example Use case to extract last line of a dataview.](https://docscdn.itrsgroup.com/faq/images/geneos/14673275408541-inline-1-image.png)

To test this, we've added a new row:

![Geneos – Gateway SQL – Example Use case to extract last line of a dataview.](https://docscdn.itrsgroup.com/faq/images/geneos/14673275408541-inline-2-image.png)

You should then see your GatewaySQL picking up the last row from the target dataview:

![Geneos – Gateway SQL – Example Use case to extract last line of a dataview.](https://docscdn.itrsgroup.com/faq/images/geneos/14673275408541-inline-3-image.png)

## Related downloads

- [lastrowxml.txt](/faq/downloads/geneos/14673275408541-33980534913693-lastrowxml.txt)


