You are here

Teradata MIN

Submitted by Asif Nowaj, Last Modified on 2019-12-18

In Teradata MIN function is used to get minimum value for a value_expression.

SYNTAX:


MINIMUM([TYPE] value_expression)  [Teradata extension to the ANSI SQL:2011 standard]
MIN([TYPE] value_expression)

Where value_expression is a literal or column expression for which the minimum value is to be computed. The expression cannot contain any ordered analytical or aggregate functions.

TYPE as ALL => that all non-null values specified by value_expression, including duplicates, are included in the minimum value computation for the group. This is the default.

TYPE as DISTINCT => that duplicate and non-null values specified by value_expression are eliminated from the minimum value computation for the group.

MIN is valid for character data as well as numeric data. MINIMUM returns the lowest sort order of a character expression. Nulls are not included in the result computation.

Teradata min

Example of MINIMUM in Teradata Used With CHARACTER Data

The following SELECT returns the immediately following result.


   SELECT MINIMUM(Name) 
   FROM Employee; 

output


   Minimum(Name)
   -------------
   Aarons A  
 

Example of Teradata minimumusing JIT Inventory

Your manufacturing shop has recently changed vendors and you know that you have no quantity of parts from that vendor that exceeds 20 items for the ProdID. You need to know how many of your other inventory items are low enough that you need to schedule a new shipment, where “low enough” is defined as fewer than 30 items in the QUANTITY column for the part.


   SELECT ProdID, MINIMUM(QUANTITY)
   FROM Inventory
   WHERE QUANTITY BETWEEN 20 AND 30
   GROUP BY ProdID
   ORDER BY ProdID;

The report is as follows:


        ProdID  Minimum(Quantity)
   -----------  -----------------
          1124                 24
          1355                 21
          3215                 25
          4391                 22

Discussion or Comment

If you have anything in mind to share, please bring it in the discussion forum here.

https://forum.everyething.com/others-f41/