ts.min() | Teradata Package for R - ts.min() - Teradata Package for R

Teradata® Package for R User Guide

Product
Teradata Package for R
Release Number
17.00
Published
July 2021
Language
English (United States)
Last Update
2023-08-08
dita:mapPath
yih1585763700215.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
B700-4005
Product Category
Teradata Vantage

The aggregate function ts.min() returns the minimum value in the column grouped by time.

Nulls are not included in the result computation.
Arguments:
  • value.expression: Specify the column for which minimum values is to be computed.

Use ts.min(distinct(column_name)) to exclude duplicate rows while calculating minimum value.

Example 1: Calculate the minimum value in the 'temperature' column of sequenced PTI table

  • Calculate the minimum value.
    > df_seq_min <- df_seq_grp %>% summarise(min_temp = ts.min(temperature))
  • Print the results.
    > df_seq_min %>% arrange(TIMECODE_RANGE, buoyid, min_temp)
    # Source:     lazy query [?? x 4]
    # Database:   [Teradata 16.20.50.01] [Teradata Native Driver 17.0.0.2]
    #   [TDAPUSER@<hostname>/TDAPUSERDB]
    # Ordered by: TIMECODE_RANGE, buoyid, min_temp
      TIMECODE_RANGE                                     `GROUP BY TIME(MINUTES(~ buoyid min_temp
      <chr>                                              <int64>                   <int>    <int>
    1 2014-01-06 08:00:00.000000+00:00,2014-01-06 08:30~ 35345                         0       10
    2 2014-01-06 09:00:00.000000+00:00,2014-01-06 09:30~ 35347                         1       70
    3 2014-01-06 10:00:00.000000+00:00,2014-01-06 10:30~ 35349                        44       43
    4 2014-01-06 10:30:00.000000+00:00,2014-01-06 11:00~ 35350                        22       23
    5 2014-01-06 10:30:00.000000+00:00,2014-01-06 11:00~ 35350                        44       43
    6 2014-01-06 21:00:00.000000+00:00,2014-01-06 21:30~ 35371                         2       80

Example 2: Calculate the minimum value in the 'temperature' column of non-PTI table

  • Calculate the minimum value.
    > df_nonpti_min <- df_nonpti %>% group_by_time(timebucket.duration = "10m", timecode.column = "TIMECODE") %>% summarise(min_temp = ts.min(temperature))
  • Print the results.
    > df_nonpti_min %>% arrange(TIMECODE_RANGE, min_temp)
    # Source:     lazy query [?? x 3]
    # Database:   [Teradata 16.20.50.01] [Teradata Native Driver 17.0.0.2]
    #   [TDAPUSER@<hostname>/TDAPUSERDB]
    # Ordered by: TIMECODE_RANGE, min_temp
      TIMECODE_RANGE                                           `GROUP BY TIME(MINUTES(1~ min_temp
      <chr>                                                    <int64>                      <int>
    1 2014-01-06 08:00:00.000000+00:00,2014-01-06 08:10:00.00~ 2314993                         10
    2 2014-01-06 08:10:00.000000+00:00,2014-01-06 08:20:00.00~ 2314994                         10
    3 2014-01-06 09:00:00.000000+00:00,2014-01-06 09:10:00.00~ 2314999                         70
    4 2014-01-06 10:00:00.000000+00:00,2014-01-06 10:10:00.00~ 2315005                         43
    5 2014-01-06 10:10:00.000000+00:00,2014-01-06 10:20:00.00~ 2315006                         43
    6 2014-01-06 10:30:00.000000+00:00,2014-01-06 10:40:00.00~ 2315008                         43
    7 2014-01-06 10:50:00.000000+00:00,2014-01-06 11:00:00.00~ 2315010                         43
    8 2014-01-06 21:00:00.000000+00:00,2014-01-06 21:10:00.00~ 2315071                         80