---
title: Transform using sql
description: Transform tabular data using custom SQL queries for filtering, aggregation, and reshaping.
category: Data Preparation
tags: [sql, transform, aggregation, filtering, table manipulation]
---

import { Aside } from "@astrojs/starlight/components";

# Transform using sql

## Description

The **Transform using SQL** activity allows users to reshape and manipulate tabular data using SQL queries. This is useful for applying complex filters, aggregating numeric values, computing derived columns, or selecting specific fields — all using standard SQL syntax.

It acts as a virtual SQL layer over the output of the previous activity, enabling analytics, data normalization, and workflow-specific transformations.

---

## Input

| **Field** | **Description**                          |
| --------- | ---------------------------------------- |
| Data      | Tabular data from the previous activity. |

> Input must have at least one column and one row to be processed.

---

## Output

| **Field**   | **Description**                                                      |
| ----------- | -------------------------------------------------------------------- |
| Transformed | The resulting table after executing the SQL query on the input data. |

> Output structure depends on the `SELECT`, `GROUP BY`, and other clauses used in the SQL query.

---

## Configuration Fields

| **Field** | **Required** | **Description**                                                                |
| --------- | ------------ | ------------------------------------------------------------------------------ |
| Query     | Yes          | The SQL query used to transform the input data. Reference actual column names. |

---

## Sample Configuration

```sql
SELECT Column1, SUM(Column2) AS Total
FROM InputTable
GROUP BY Column1
```

> Note: `InputTable` is the alias for the input dataset provided automatically by the system.

---

## Sample Input

| Column1 | Column2 | Column3 |
| ------- | ------- | ------- |
| A       | 50      | 120     |
| B       | 30      | 90      |
| A       | 20      | 150     |
| B       | 40      | 110     |
| C       | 25      | 130     |

---

## Sample Output

| Column1 | Total |
| ------- | ----- |
| A       | 70    |
| B       | 70    |
| C       | 25    |

---

<Aside>

Table Names Can be selected for the query by clicking on the Fx button
![alt text](transform-using-sql-img-02.jpg)

As shown below

![alt text](transform-using-sql-img-03.png)

</Aside>
