SlideShare a Scribd company logo
Analytical Functions
After completing this module, you will be able to:
• Enable and Expedite the processing OLAP queries
• Describe the Derivation of Ordered Analytical Functions
Analytical functions
„ Support common operation in analytical and data mining
environment
„ Includes ANSI SQL-99 compliant window functions as well as
Teradata-specific functions
„ It used in Expression list of SELECT statement
Aggregate function Lists
„ Window aggregate functions
„ AVG
„ COUNT
„ MAX
„ MIN
„ SUM
„ Rank function
„ RANK
„ Distribution function
„ PERCENT_RANK
„ Row number function
„ ROW_NUMBER
„ Teradata-specific functions
„ CSUM
„ MAVG
„ MDIFF
„ MLINREG
„ MSUM
„ QUANTILE
„ RANK
Windows Aggregate Functions
Window Feature
Ć’ Provides dynamic subset data definition
Ć’ ANSI SQL-99 Compliant
Window Clauses
Entire partition following the current row
UNBOUNDED
FOLLOWING
Entire partition preceding the current row
UNBOUNDED
PRECEDING
starting point for the aggregation group within the
Partition.
ROWS
Grouping of rows based on column specified
PARTITION BY
arguments that define how values are grouped, ordered.
OVER
Description
Syntax Element
Computation types
ROWS BETWEEN UNBOUNDED PRECEDING AND
UNBOUNDED FOLLOWING
Group
„ ROWS UNBOUNDED PRECEDING
„ ROWS BETWEEN UNBOUNDED PRECEDING AND value
PRECEDING
„ ROWS BETWEEN UNBOUNDED PRECEDING AND
CURRENT ROW
„ ROWS BETWEEN UNBOUNDED PRECEDING AND
value FOLLOWING
Cumulative
Syntax options
Computation
Computation types contd..
„ ROWS BETWEEN value PRECEDING AND UNBOUNDED
FOLLOWING
„ ROWS BETWEEN CURRENT ROW AND UNBOUNDED
FOLLOWING
„ ROWS BETWEEN value FOLLOWING AND UNBOUNDED
FOLLOWING
Remaining
„ ROWS value PRECEDING
„ ROWS CURRENT ROW
„ ROWS BETWEEN value PRECEDING AND value PRECEDING
„ ROWS BETWEEN value PRECEDING AND CURRENT ROW
„ ROWS BETWEEN value PRECEDING AND value FOLLOWING
„ ROWS BETWEEN CURRENT ROW AND CURRENT ROW
„ ROWS BETWEEN CURRENT ROW AND value FOLLOWING
„ ROWS BETWEEN value FOLLOWING AND value FOLLOWING
Moving
Syntax options
Computation
Analytical functions
select state, zip_code ,
Balance_Forward,
SUM(Balance_Forward) OVER( PARTITION BY Zip_Code
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED
FOLLOWING)
FROM
AU.accounts;
• SUM
• Result
State Zip_Code Balance_F Grouped Sum(Balance_Forward
CA 90020 5003.8 16950545.29
CA 90020 2582.3 16950545.29
CA 90066 1849.26 14484617.91
CA 90066 8392.2 14484617.91
CA 90066 9948.5 14484617.91
Analytical functions
select state, zip_code ,
Balance_Forward,
SUM(Balance_Forward) OVER( PARTITION BY State order by Zip_Code
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED
FOLLOWING)
FROM
AU.accounts;
• AVG
• Result
State Zip_Code Balance_Forward Moving Avg(Balance_Forward)
CA 90020 18419.5 18420
CA 90020 7571.97 12996
CA 90020 2265.76 9419
CA 90020 2707.29 4182
CA 90020 17572.4 7515
CA 90020 5160.96 8480
Analytical functions
select Account_number, Trans_number ,
Trans_amount,
MIN(Trans_Amount) OVER( PARTITION BY Account_number
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED
FOLLOWING)
FROM
AU.Trans
•MIN
• Result
Account_Number Trans_Number Trans_amount Cumulative Max(Trans_Amount)
20025236 1235 94.42 94.42
20025236 11235 102 94.42
20025237 1236 -94.5 -94.5
20025237 21455 106 -94.5
20025237 22458 252 -94.5
20025238 1237 -94.57 -94.57
20025239 1238 -94.65 -94.65
20025239 12238 103 -94.65
Analytical functions
select Account_number, Trans_number ,
Trans_amount,
MAX(Trans_Amount) OVER( PARTITION BY Account_number
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED
FOLLOWING)
FROM
AU.Trans
• MAX
• Result
Account_Number Trans_Number Trans_amount Cumulative Max(Trans_Amount)
20025236 1235 94.42 102
20025236 11235 102 102
20025237 1236 -94.5 252
20025237 21455 106 252
20025237 22458 252 252
20025238 1237 -94.57 -94.57
20025239 1238 -94.65 103
20025239 12238 103 103
RANK Function
„ Returns the rank (1 … n) of all the rows in the group by the value of
sort_expression_list, with the same sort_expression values receiving the same
rank.
„ It is Teradata Extension to ANSI
„ Window Aggregate need to use for ANSI SQL-99
select
Account_number,
Trans_Amount,
RANK(Trans_Amount)
from
AU.Trans
select Account_number,
Trans_Amount,
RANK() OVER(ORDER BY
TRANS_AMOUNT DESC)
from AU.Trans
•Teradata Extn. •ANSI SQL-99
Account_Number Trans_Amount Rank(Trans_Amount)
20033997 2044 1
20033987 2042 2
20033977 2040 3
20033967 2038 4
20033957 2036 5
PERCENT RANK Function
„ Returns the relative rank of rows for a value_expression.
„ SQL-99 window function.
Select
Account_number,
Trans_Amount,
PERCENT_RANK()
OVER(ORDER BY TRANS_AMOUNT DESC)
from
AU.Trans
Account_Number Trans_Amount Percent Rank(Trans_Amount)
20033997 2044 0.000000
20033987 2042 0.000067
20033977 2040 0.000133
20033967 2038 0.000200
20033957 2036 0.000267
ROW NUMBER Function
„ Returns the sequential row number, where the first row is number one, of the
row within its window partition according to the window ordering of the window.
„ SQL-99 window function.
Account_Number Trans_Amount Row Number()
20033997 2044 1
20033987 2042 2
20033977 2040 3
20033967 2038 4
20033957 2036 5
select Account_number, Trans_Amount,
ROW_NUMBER() OVER(ORDER BY TRANS_AMOUNT DESC)
from AU.Trans
CSUM Function
„ Returns the cumulative (or running) sum of a column expression,
assuming the rows are sorted by sort_expression_list.
„ Teradata-specific function.
select
Account_number,
Trans_Amount,
CSUM(Trans_Amount, Account_number desc)
from
au.Trans
Account_Number Trans_Amount CSum(Trans_Amount,1)
20034000 -764.45 -764.45
20033999 -764.37 -1528.82
20033999 833 -695.82
20033998 -764.3 -1460.12
20033997 -764.22 -2224.34
20033997 2044 -180.34
MAVG Function
„ Returns the moving difference between the current row-column value and
the preceding nth row-column value.
„ Teradata-specific function.
select
Account_number,
Trans_Amount,
MAVG(Trans_Amount, 2, Account_number desc)
from
au.Trans
Account_Number Trans_Amount mount,2,Account_Number DESC)
20034000 -764.45 -764
20033999 -764.37 -764
20033999 833 34
20033998 -764.3 34
20033997 -764.22 -764
20033997 2044 640
MDIFF Function
„ Computes the moving average of a column using the current row and the
preceding width-1 rows.
„ Teradata-specific function.
select
Account_number,
Trans_Amount,
MDIFF(Trans_Amount, 1, Account_number desc)
from
au.Trans
Account_Number Trans_Amount mount,1,Account_Number DESC)
20034000 -764.45 ?
20033999 -764.37 0.08
20033999 833 1597.37
20033998 -764.3 -1597.30
20033997 -764.22 0.08
20033997 2044 2808.22
MSUM Function
„ Computes the moving sum of a column using the current row and the
preceding n-1 rows. This function is very similar to the MAVG function.
„ Teradata-specific function.
select
Account_number,
Trans_Amount,
MSUM(Trans_Amount, 1, Account_number desc)
from
au.Trans
Account_Number Trans_Amount mount,1,Account_Number DESC)
20034000 -764.45 -764.45
20033999 -764.37 -764.37
20033999 833 833.00
20033998 -764.3 -764.30
20033997 -764.22 -764.22
20033997 2044 2044.00
QUANTILE Function
„ Computes the moving sum of a column using the current row and the
preceding n-1 rows. This function is very similar to the MAVG function.
„ Teradata-specific function.
select
Account_number,
Trans_Amount,
QUANTILE(1000, Trans_Amount ASC)
from
au.Trans
Account_Number Trans_AmountQuantile(1000,Trans_Amount ASC)
20033985 -763.3 999
20033984 -763.23 999
20033983 -763.15 999
20033997 -764.22 999
20033975 -762.54 998
20033982 -763.07 998
20033980 -762.92 998

More Related Content

PDF
MySQL 8.0 Optimizer Guide
Morgan Tocker
 
PDF
Lecture 5: Convolutional Neural Network Models
Mohamed Loey
 
PPTX
Ppt on pivot table
Hemendra Vyas
 
PPT
Bubble sort a best presentation topic
Saddam Hussain
 
PPTX
14_cnn complete.pptx
FaizanNadeem10
 
PPTX
Multi ways trees
SHEETAL WAGHMARE
 
PPTX
Advanced Filter in Excel
dinesh takyar
 
PPTX
Sorting
Ashim Lamichhane
 
MySQL 8.0 Optimizer Guide
Morgan Tocker
 
Lecture 5: Convolutional Neural Network Models
Mohamed Loey
 
Ppt on pivot table
Hemendra Vyas
 
Bubble sort a best presentation topic
Saddam Hussain
 
14_cnn complete.pptx
FaizanNadeem10
 
Multi ways trees
SHEETAL WAGHMARE
 
Advanced Filter in Excel
dinesh takyar
 
Sorting
Ashim Lamichhane
 

Similar to 5.Analytical Function.pdf (20)

PPSX
Analytic & Windowing functions in oracle
Logan Palanisamy
 
PDF
Oracle_Analytical_function.pdf
KalyankumarVenkat1
 
PPT
Olap Functions Suport in Informix
Bingjie Miao
 
PPT
Enabling Applications with Informix' new OLAP functionality
Ajay Gupte
 
PDF
Window functions in MariaDB 10.2
Sergey Petrunya
 
PDF
Building advanced data-driven applications
MariaDB plc
 
PDF
Data Love Conference - Window Functions for Database Analytics
Dave Stokes
 
PPTX
SQL Windowing
Sandun Perera
 
PPTX
Project report aditi paul1
guest9529cb
 
PPTX
Oracle sql analytic functions
mamamowebby
 
PPTX
Exploring Advanced SQL Techniques Using Analytic Functions
Zohar Elkayam
 
PPTX
Exploring Advanced SQL Techniques Using Analytic Functions
Zohar Elkayam
 
PDF
Oracle Advanced SQL and Analytic Functions
Zohar Elkayam
 
PDF
Window functions for Data Science
Mark Tabladillo
 
PDF
Window functions in MySQL 8.0
Mydbops
 
PDF
OOW2016: Exploring Advanced SQL Techniques Using Analytic Functions
Zohar Elkayam
 
PPTX
Mastering T-SQL Window Functions
Jose Rivera Miranda
 
PDF
M|18 Understanding the Query Optimizer
MariaDB plc
 
PPTX
Windowing functions session for Slovak SQL Pass & BI
Andrej Zafka
 
PPTX
Advanced functions in PL SQL
Hosein Zare
 
Analytic & Windowing functions in oracle
Logan Palanisamy
 
Oracle_Analytical_function.pdf
KalyankumarVenkat1
 
Olap Functions Suport in Informix
Bingjie Miao
 
Enabling Applications with Informix' new OLAP functionality
Ajay Gupte
 
Window functions in MariaDB 10.2
Sergey Petrunya
 
Building advanced data-driven applications
MariaDB plc
 
Data Love Conference - Window Functions for Database Analytics
Dave Stokes
 
SQL Windowing
Sandun Perera
 
Project report aditi paul1
guest9529cb
 
Oracle sql analytic functions
mamamowebby
 
Exploring Advanced SQL Techniques Using Analytic Functions
Zohar Elkayam
 
Exploring Advanced SQL Techniques Using Analytic Functions
Zohar Elkayam
 
Oracle Advanced SQL and Analytic Functions
Zohar Elkayam
 
Window functions for Data Science
Mark Tabladillo
 
Window functions in MySQL 8.0
Mydbops
 
OOW2016: Exploring Advanced SQL Techniques Using Analytic Functions
Zohar Elkayam
 
Mastering T-SQL Window Functions
Jose Rivera Miranda
 
M|18 Understanding the Query Optimizer
MariaDB plc
 
Windowing functions session for Slovak SQL Pass & BI
Andrej Zafka
 
Advanced functions in PL SQL
Hosein Zare
 
Ad

More from ssuser8b6c85 (10)

PDF
5.Agg. Function.pdf
ssuser8b6c85
 
PDF
2.1 Data types.pdf
ssuser8b6c85
 
PDF
1.8 Data Protection.pdf
ssuser8b6c85
 
PDF
1.6 PI Mechanics.pdf
ssuser8b6c85
 
PDF
1.5 PI Access.pdf
ssuser8b6c85
 
PDF
1.4 System Arch.pdf
ssuser8b6c85
 
PDF
Spark basic.pdf
ssuser8b6c85
 
PDF
1.1 Overview.pdf
ssuser8b6c85
 
PDF
1.1 Intro to WinDDI.pdf
ssuser8b6c85
 
PDF
6.3 Mload.pdf
ssuser8b6c85
 
5.Agg. Function.pdf
ssuser8b6c85
 
2.1 Data types.pdf
ssuser8b6c85
 
1.8 Data Protection.pdf
ssuser8b6c85
 
1.6 PI Mechanics.pdf
ssuser8b6c85
 
1.5 PI Access.pdf
ssuser8b6c85
 
1.4 System Arch.pdf
ssuser8b6c85
 
Spark basic.pdf
ssuser8b6c85
 
1.1 Overview.pdf
ssuser8b6c85
 
1.1 Intro to WinDDI.pdf
ssuser8b6c85
 
6.3 Mload.pdf
ssuser8b6c85
 
Ad

Recently uploaded (20)

PPTX
World-population.pptx fire bunberbpeople
umutunsalnsl4402
 
PPTX
lecture 13 mind test academy it skills.pptx
ggesjmrasoolpark
 
PPTX
Future_of_AI_Presentation for everyone.pptx
boranamanju07
 
PPTX
MR and reffffffvvvvvvvfversal_083605.pptx
manjeshjain
 
PPTX
HSE WEEKLY REPORT for dummies and lazzzzy.pptx
ahmedibrahim691723
 
PDF
An Uncut Conversation With Grok | PDF Document
Mike Hydes
 
PDF
Key_Statistical_Techniques_in_Analytics_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
blockchain123456789012345678901234567890
tanvikhunt1003
 
PPTX
Presentation on animal welfare a good topic
kidscream385
 
PPTX
short term internship project on Data visualization
JMJCollegeComputerde
 
PDF
Mastering Financial Analysis Materials.pdf
SalamiAbdullahi
 
PPTX
Introduction to Biostatistics Presentation.pptx
AtemJoshua
 
PPTX
Data-Users-in-Database-Management-Systems (1).pptx
dharmik832021
 
PPTX
Introduction-to-Python-Programming-Language (1).pptx
dhyeysapariya
 
PPTX
Introduction to computer chapter one 2017.pptx
mensunmarley
 
PPTX
Introduction to Data Analytics and Data Science
KavithaCIT
 
PDF
202501214233242351219 QASS Session 2.pdf
lauramejiamillan
 
PPTX
Databricks-DE-Associate Certification Questions-june-2024.pptx
pedelli41
 
PDF
D9110.pdfdsfvsdfvsdfvsdfvfvfsvfsvffsdfvsdfvsd
minhn6673
 
PPTX
Web dev -ppt that helps us understand web technology
shubhragoyal12
 
World-population.pptx fire bunberbpeople
umutunsalnsl4402
 
lecture 13 mind test academy it skills.pptx
ggesjmrasoolpark
 
Future_of_AI_Presentation for everyone.pptx
boranamanju07
 
MR and reffffffvvvvvvvfversal_083605.pptx
manjeshjain
 
HSE WEEKLY REPORT for dummies and lazzzzy.pptx
ahmedibrahim691723
 
An Uncut Conversation With Grok | PDF Document
Mike Hydes
 
Key_Statistical_Techniques_in_Analytics_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
blockchain123456789012345678901234567890
tanvikhunt1003
 
Presentation on animal welfare a good topic
kidscream385
 
short term internship project on Data visualization
JMJCollegeComputerde
 
Mastering Financial Analysis Materials.pdf
SalamiAbdullahi
 
Introduction to Biostatistics Presentation.pptx
AtemJoshua
 
Data-Users-in-Database-Management-Systems (1).pptx
dharmik832021
 
Introduction-to-Python-Programming-Language (1).pptx
dhyeysapariya
 
Introduction to computer chapter one 2017.pptx
mensunmarley
 
Introduction to Data Analytics and Data Science
KavithaCIT
 
202501214233242351219 QASS Session 2.pdf
lauramejiamillan
 
Databricks-DE-Associate Certification Questions-june-2024.pptx
pedelli41
 
D9110.pdfdsfvsdfvsdfvsdfvfvfsvfsvffsdfvsdfvsd
minhn6673
 
Web dev -ppt that helps us understand web technology
shubhragoyal12
 

5.Analytical Function.pdf

  • 1. Analytical Functions After completing this module, you will be able to: • Enable and Expedite the processing OLAP queries • Describe the Derivation of Ordered Analytical Functions
  • 2. Analytical functions „ Support common operation in analytical and data mining environment „ Includes ANSI SQL-99 compliant window functions as well as Teradata-specific functions „ It used in Expression list of SELECT statement
  • 3. Aggregate function Lists „ Window aggregate functions „ AVG „ COUNT „ MAX „ MIN „ SUM „ Rank function „ RANK „ Distribution function „ PERCENT_RANK „ Row number function „ ROW_NUMBER „ Teradata-specific functions „ CSUM „ MAVG „ MDIFF „ MLINREG „ MSUM „ QUANTILE „ RANK
  • 4. Windows Aggregate Functions Window Feature Ć’ Provides dynamic subset data definition Ć’ ANSI SQL-99 Compliant Window Clauses Entire partition following the current row UNBOUNDED FOLLOWING Entire partition preceding the current row UNBOUNDED PRECEDING starting point for the aggregation group within the Partition. ROWS Grouping of rows based on column specified PARTITION BY arguments that define how values are grouped, ordered. OVER Description Syntax Element
  • 5. Computation types ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING Group „ ROWS UNBOUNDED PRECEDING „ ROWS BETWEEN UNBOUNDED PRECEDING AND value PRECEDING „ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW „ ROWS BETWEEN UNBOUNDED PRECEDING AND value FOLLOWING Cumulative Syntax options Computation
  • 6. Computation types contd.. „ ROWS BETWEEN value PRECEDING AND UNBOUNDED FOLLOWING „ ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING „ ROWS BETWEEN value FOLLOWING AND UNBOUNDED FOLLOWING Remaining „ ROWS value PRECEDING „ ROWS CURRENT ROW „ ROWS BETWEEN value PRECEDING AND value PRECEDING „ ROWS BETWEEN value PRECEDING AND CURRENT ROW „ ROWS BETWEEN value PRECEDING AND value FOLLOWING „ ROWS BETWEEN CURRENT ROW AND CURRENT ROW „ ROWS BETWEEN CURRENT ROW AND value FOLLOWING „ ROWS BETWEEN value FOLLOWING AND value FOLLOWING Moving Syntax options Computation
  • 7. Analytical functions select state, zip_code , Balance_Forward, SUM(Balance_Forward) OVER( PARTITION BY Zip_Code ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM AU.accounts; • SUM • Result State Zip_Code Balance_F Grouped Sum(Balance_Forward CA 90020 5003.8 16950545.29 CA 90020 2582.3 16950545.29 CA 90066 1849.26 14484617.91 CA 90066 8392.2 14484617.91 CA 90066 9948.5 14484617.91
  • 8. Analytical functions select state, zip_code , Balance_Forward, SUM(Balance_Forward) OVER( PARTITION BY State order by Zip_Code ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM AU.accounts; • AVG • Result State Zip_Code Balance_Forward Moving Avg(Balance_Forward) CA 90020 18419.5 18420 CA 90020 7571.97 12996 CA 90020 2265.76 9419 CA 90020 2707.29 4182 CA 90020 17572.4 7515 CA 90020 5160.96 8480
  • 9. Analytical functions select Account_number, Trans_number , Trans_amount, MIN(Trans_Amount) OVER( PARTITION BY Account_number ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM AU.Trans •MIN • Result Account_Number Trans_Number Trans_amount Cumulative Max(Trans_Amount) 20025236 1235 94.42 94.42 20025236 11235 102 94.42 20025237 1236 -94.5 -94.5 20025237 21455 106 -94.5 20025237 22458 252 -94.5 20025238 1237 -94.57 -94.57 20025239 1238 -94.65 -94.65 20025239 12238 103 -94.65
  • 10. Analytical functions select Account_number, Trans_number , Trans_amount, MAX(Trans_Amount) OVER( PARTITION BY Account_number ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM AU.Trans • MAX • Result Account_Number Trans_Number Trans_amount Cumulative Max(Trans_Amount) 20025236 1235 94.42 102 20025236 11235 102 102 20025237 1236 -94.5 252 20025237 21455 106 252 20025237 22458 252 252 20025238 1237 -94.57 -94.57 20025239 1238 -94.65 103 20025239 12238 103 103
  • 11. RANK Function „ Returns the rank (1 … n) of all the rows in the group by the value of sort_expression_list, with the same sort_expression values receiving the same rank. „ It is Teradata Extension to ANSI „ Window Aggregate need to use for ANSI SQL-99 select Account_number, Trans_Amount, RANK(Trans_Amount) from AU.Trans select Account_number, Trans_Amount, RANK() OVER(ORDER BY TRANS_AMOUNT DESC) from AU.Trans •Teradata Extn. •ANSI SQL-99 Account_Number Trans_Amount Rank(Trans_Amount) 20033997 2044 1 20033987 2042 2 20033977 2040 3 20033967 2038 4 20033957 2036 5
  • 12. PERCENT RANK Function „ Returns the relative rank of rows for a value_expression. „ SQL-99 window function. Select Account_number, Trans_Amount, PERCENT_RANK() OVER(ORDER BY TRANS_AMOUNT DESC) from AU.Trans Account_Number Trans_Amount Percent Rank(Trans_Amount) 20033997 2044 0.000000 20033987 2042 0.000067 20033977 2040 0.000133 20033967 2038 0.000200 20033957 2036 0.000267
  • 13. ROW NUMBER Function „ Returns the sequential row number, where the first row is number one, of the row within its window partition according to the window ordering of the window. „ SQL-99 window function. Account_Number Trans_Amount Row Number() 20033997 2044 1 20033987 2042 2 20033977 2040 3 20033967 2038 4 20033957 2036 5 select Account_number, Trans_Amount, ROW_NUMBER() OVER(ORDER BY TRANS_AMOUNT DESC) from AU.Trans
  • 14. CSUM Function „ Returns the cumulative (or running) sum of a column expression, assuming the rows are sorted by sort_expression_list. „ Teradata-specific function. select Account_number, Trans_Amount, CSUM(Trans_Amount, Account_number desc) from au.Trans Account_Number Trans_Amount CSum(Trans_Amount,1) 20034000 -764.45 -764.45 20033999 -764.37 -1528.82 20033999 833 -695.82 20033998 -764.3 -1460.12 20033997 -764.22 -2224.34 20033997 2044 -180.34
  • 15. MAVG Function „ Returns the moving difference between the current row-column value and the preceding nth row-column value. „ Teradata-specific function. select Account_number, Trans_Amount, MAVG(Trans_Amount, 2, Account_number desc) from au.Trans Account_Number Trans_Amount mount,2,Account_Number DESC) 20034000 -764.45 -764 20033999 -764.37 -764 20033999 833 34 20033998 -764.3 34 20033997 -764.22 -764 20033997 2044 640
  • 16. MDIFF Function „ Computes the moving average of a column using the current row and the preceding width-1 rows. „ Teradata-specific function. select Account_number, Trans_Amount, MDIFF(Trans_Amount, 1, Account_number desc) from au.Trans Account_Number Trans_Amount mount,1,Account_Number DESC) 20034000 -764.45 ? 20033999 -764.37 0.08 20033999 833 1597.37 20033998 -764.3 -1597.30 20033997 -764.22 0.08 20033997 2044 2808.22
  • 17. MSUM Function „ Computes the moving sum of a column using the current row and the preceding n-1 rows. This function is very similar to the MAVG function. „ Teradata-specific function. select Account_number, Trans_Amount, MSUM(Trans_Amount, 1, Account_number desc) from au.Trans Account_Number Trans_Amount mount,1,Account_Number DESC) 20034000 -764.45 -764.45 20033999 -764.37 -764.37 20033999 833 833.00 20033998 -764.3 -764.30 20033997 -764.22 -764.22 20033997 2044 2044.00
  • 18. QUANTILE Function „ Computes the moving sum of a column using the current row and the preceding n-1 rows. This function is very similar to the MAVG function. „ Teradata-specific function. select Account_number, Trans_Amount, QUANTILE(1000, Trans_Amount ASC) from au.Trans Account_Number Trans_AmountQuantile(1000,Trans_Amount ASC) 20033985 -763.3 999 20033984 -763.23 999 20033983 -763.15 999 20033997 -764.22 999 20033975 -762.54 998 20033982 -763.07 998 20033980 -762.92 998