# tickscript.select() function

`tickscript.select()` is a user-contributed function maintained by the package author and can be updated or removed at any time.

`tickscript.select()` changes a column’s name and optionally applies an aggregate or selector function to values in the column.

## TICKscript helper function

`tickscript.select()` is a helper function meant to replicate TICKscript operations like the following:

``````// Rename
query("SELECT x AS y")

// Aggregate and rename
query("SELECT f(x) AS y")
``````
##### Function type signature
``````(<-tables: B, as: string, ?column: A, ?fn: (<-: B, column: A) => stream[C]) => stream[D] where A: Equatable, C: Record, D: Record
``````
For more information, see Function type signatures.

## Parameters

### column

Column to operate on. Default is `_value`.

### fn

Aggregate or selector function to apply.

### as

(Required) New column name.

### tables

Input data. Default is piped-forward data (`<-`).

## Examples

### Change the name of the value column

``````import "contrib/bonitoo-io/tickscript"
import "sampledata"

sampledata.int()
|> tickscript.select(as: "example-name")

``````

View example input and ouput

### Change the name of the value column and apply an aggregate function

``````import "contrib/bonitoo-io/tickscript"
import "sampledata"

sampledata.int()
|> tickscript.select(as: "sum", fn: sum)

``````

View example input and ouput

### Change the name of the value column and apply a selector function

``````import "contrib/bonitoo-io/tickscript"
import "sampledata"

sampledata.int()
|> tickscript.select(as: "max", fn: max)

``````

View example input and ouput
{"ft_lang_label":"__label__en","ft_lang_prob":0.5468719,"math_prob":0.6414977,"size":1937,"snap":"2022-40-2023-06","text_gpt3_token_len":460,"char_repetition_ratio":0.15882048,"word_repetition_ratio":0.22743683,"special_character_ratio":0.22044398,"punctuation_ratio":0.14326647,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96895206,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-09-25T12:04:36Z\",\"WARC-Record-ID\":\"<urn:uuid:e7a1813d-74ec-4f13-b1da-6232f025f46c>\",\"Content-Length\":\"195129\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:0988648f-ea04-457c-a423-30b101208c25>\",\"WARC-Concurrent-To\":\"<urn:uuid:05616137-def2-43e6-b446-cbda98b46ef3>\",\"WARC-IP-Address\":\"18.154.227.97\",\"WARC-Target-URI\":\"https://test2.docs.influxdata.com/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select/\",\"WARC-Payload-Digest\":\"sha1:G45GYBU5ABNECU5D6KOQIXCRAKW5LZIF\",\"WARC-Block-Digest\":\"sha1:SDX6JX2Q2KYVTVB3LYFFFCUEEJ4PYBPT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-40/CC-MAIN-2022-40_segments_1664030334528.24_warc_CC-MAIN-20220925101046-20220925131046-00453.warc.gz\"}"}