[discrete]
[[esql-eval]]
=== `EVAL`

The `EVAL` processing command enables you to append new columns with calculated
values.

**Syntax**

[source,esql]
----
EVAL [column1 =] value1[, ..., [columnN =] valueN]
----

*Parameters*

`columnX`::
The column name.
If a column with the same name already exists, the existing column is dropped.
If a column name is used more than once, only the rightmost duplicate creates a column.

`valueX`::
The value for the column. Can be a literal, an expression, or a
<<esql-functions,function>>. Can use columns defined left of this one.

*Description*

The `EVAL` processing command enables you to append new columns with calculated
values. `EVAL` supports various functions for calculating values. Refer to
<<esql-functions,Functions>> for more information.

*Examples*

[source.merge.styled,esql]
----
include::{esql-specs}/eval.csv-spec[tag=eval]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/eval.csv-spec[tag=eval-result]
|===

If the specified column already exists, the existing column will be dropped, and
the new column will be appended to the table:

[source.merge.styled,esql]
----
include::{esql-specs}/eval.csv-spec[tag=evalReplace]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/eval.csv-spec[tag=evalReplace-result]
|===

Specifying the output column name is optional. If not specified, the new column
name is equal to the expression. The following query adds a column named
`height*3.281`:

[source.merge.styled,esql]
----
include::{esql-specs}/eval.csv-spec[tag=evalUnnamedColumn]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/eval.csv-spec[tag=evalUnnamedColumn-result]
|===

Because this name contains special characters, <<esql-identifiers,it needs to be
quoted>> with backticks (+{backtick}+) when using it in subsequent commands:

[source.merge.styled,esql]
----
include::{esql-specs}/eval.csv-spec[tag=evalUnnamedColumnStats]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/eval.csv-spec[tag=evalUnnamedColumnStats-result]
|===
