> For the complete documentation index, see [llms.txt](https://upsolver.gitbook.io/content/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://upsolver.gitbook.io/content/reference-1/functions-and-operators/operators/mathematical.md).

# Mathematical

## Mathematical operators

<table><thead><tr><th width="220">Operator</th><th>Description</th></tr></thead><tbody><tr><td><code>+</code></td><td><a href="#addition">Addition</a></td></tr><tr><td><code>-</code></td><td><a href="#subtraction">Subtraction</a> or <a href="#negation">negation</a></td></tr><tr><td><code>*</code></td><td><a href="#multiplication">Multiplication</a></td></tr><tr><td><code>/</code></td><td><a href="#division">Division</a> (integer division performs truncation)</td></tr><tr><td><code>_/</code></td><td><a href="#integer-division">Integer division</a></td></tr><tr><td><code>%</code></td><td><a href="#modulus">Modulus</a> (remainder)</td></tr><tr><td><code>^</code></td><td><a href="#power">Power</a></td></tr></tbody></table>

## Addition

Sums two numbers.

### Examples

#### SQL

```sql
CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true	
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data 
  MAP_COLUMNS_BY_NAME
    SELECT 
        1 + 1 AS add_example1,
        1 + 2 + 3 AS add_example2,
        1.1 + 2.2 AS add_example3
    FROM default_glue_catalog.upsolver_samples.orders_raw_data 
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;
```

#### Query result

| add\_example1 | add\_example2 | add\_example3      |
| ------------- | ------------- | ------------------ |
| 2             | 6             | 3.3000000000000003 |

## Subtraction

Subtracts one number from another.

### Examples

#### SQL

```sql
CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true	
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data 
  MAP_COLUMNS_BY_NAME
    SELECT 
        1 - 1 AS sub_example1,
        1 - 2 - 3 AS sub_example2,
        2.2 - 1.1 AS sub_example3
    FROM default_glue_catalog.upsolver_samples.orders_raw_data 
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;
```

#### Query result

| sub\_example1 | sub\_example2 | sub\_example3 |
| ------------- | ------------- | ------------- |
| 0             | -4            | 1.1           |

## Negation

Negates the value of a number.

### Examples

#### SQL

```sql
CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true	
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data 
  MAP_COLUMNS_BY_NAME
    SELECT 
        - 1 AS neg_example1,
        - (- 1) AS neg_example2,
        - 0 AS neg_example3
    FROM default_glue_catalog.upsolver_samples.orders_raw_data 
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;
```

#### Query result

| neg\_example1 | neg\_example2 | neg\_example3 |
| ------------- | ------------- | ------------- |
| -1            | 1             | 0             |

## Multiplication

Multiplies two numbers.

### Examples

#### SQL

```sql
CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true	
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data 
  MAP_COLUMNS_BY_NAME
    SELECT 
        1 * 0 AS mult_example1,
        1 * 2 * 3 AS mult_example2,
        1.1 * 2.2 AS mult_example3
    FROM default_glue_catalog.upsolver_samples.orders_raw_data 
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;
```

#### Query result

| mult\_example1 | mult\_example2 | mult\_example3     |
| -------------- | -------------- | ------------------ |
| 0              | 6              | 2.4200000000000004 |

## Division

Divides one number with another.

Note that when dividing integers, the result is truncated, meaning that only the integer portion of the result is returned if the numbers do not divide evenly.

### Examples

#### SQL

```sql
CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true	
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data 
  MAP_COLUMNS_BY_NAME
    SELECT 
        4 / 2 AS div_example1,
        4 / 2 / 2 AS div_example2,
        3 / 4 AS div_example3,
        2.2 / 3.3 AS div_example4
    FROM default_glue_catalog.upsolver_samples.orders_raw_data 
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;
```

#### Query result

<table><thead><tr><th width="174">div_example1</th><th width="156">div_example2</th><th width="171">div_example3</th><th>div_example4</th></tr></thead><tbody><tr><td>2</td><td>1</td><td>0</td><td>0.6666666666666667</td></tr></tbody></table>

## Integer division

Divides one integer from another.

Inputs that are not integers are truncated and then divided.

### Examples

#### SQL

```sql
CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true	
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data 
  MAP_COLUMNS_BY_NAME
    SELECT 
        4 _/ 3 as div_example1,
        4.1 _/ 3.1 as div_example2,
        4.1 / 3.1 as div_example3,
        4.8 _/ 3.8 as div_example4,
        4.8 / 3.8 as div_example5,
    FROM default_glue_catalog.upsolver_samples.orders_raw_data 
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;
```

#### Query result

| div\_example1 | div\_example2 | div\_example3       | div\_example4 | div\_example5     |
| ------------- | ------------- | ------------------- | ------------- | ----------------- |
| 1             | 1             | 1.3225,806451612903 | 1             | 1.263157894736842 |

## Modulus

Computes the modulus (remainder) from dividing one number with another.

### Examples

#### SQL

```sql
CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true	
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data 
  MAP_COLUMNS_BY_NAME
    SELECT 
        4 % 3 AS mod_example1,
        10 % 4 % 2 AS mod_example2,
        5.5 % 2.2 AS mod_example3
    FROM default_glue_catalog.upsolver_samples.orders_raw_data 
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;
```

#### Query result

| mod\_example1 | mod\_example2 | mod\_example3      |
| ------------- | ------------- | ------------------ |
| 1             | 0             | 1.0999999999999996 |

## Power

Raises one number to the power of another.

This operator has the same functionality as [`POW`](/content/reference-1/functions-and-operators/functions/mathematical/pow.md) and [`POWER`](/content/reference-1/functions-and-operators/functions/mathematical/power.md).

#### SQL

```sql
CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true	
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data 
  MAP_COLUMNS_BY_NAME
    SELECT 
        2 ^ 2 AS pow_example1,
        3.3 ^ 1.1 AS pow_example2
    FROM default_glue_catalog.upsolver_samples.orders_raw_data 
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;
```

#### Query result

| pow\_example1 | pow\_example2     |
| ------------- | ----------------- |
| 4             | 3.718479005997499 |

## Example with sample data

The following example uses Upsolver sample data that is available to you through Upsolver.

#### SQL

```sql
CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true	
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data 
  MAP_COLUMNS_BY_NAME
    SELECT 
        orderid AS order_id,
        ROUND(nettotal / (1 + taxrate), 2) AS pretax_total,
        taxrate,
        nettotal
    FROM default_glue_catalog.upsolver_samples.orders_raw_data 
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 3;
```

#### Query result

| order\_id  | pretax\_total | taxrate | nettotal |
| ---------- | ------------- | ------- | -------- |
| NzwdlehpJ9 | 349.98        | 0.12    | 391.98   |
| 6nDo5vqL3B | 741.95        | 0.12    | 830.98   |
| mqEu3Y96pE | 1157.74       | 0.12    | 1296.67  |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://upsolver.gitbook.io/content/reference-1/functions-and-operators/operators/mathematical.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
