How to do it...

  1. Connect to Teradata Database using SQLA or Studio.
  2. Execute the following query to get the result set:
/*OLAP select*/
SELECT
EMP_ID, SAL_Months, sale_done, sale_target, min(sale_done) OVER ( PARTITION BY EMP_ID ORDER BY
SAL_Months ROWS 2 PRECEDING) FROM EMP_SAL;
  1. The result set will have the minimum amount of sales from employees in 3 months.
  2. The RANK and ORDER BY functions will be used to sort rows in ascending and descending order as shown in code.