0% found this document useful (0 votes)
6 views

AMDP Functions

Uploaded by

vinodakunuru17
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

AMDP Functions

Uploaded by

vinodakunuru17
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Using AMDP in Some Useful Functions

ROW_NUMBER( ), RANK( ) and DENSE_RANK( ) in HANA SQL Script


ROW_NUMBER ( )– Function is used to generate a sequential number and assign to each row in the
result set table. Then this column can be used do perform different sorting operation on the result set.

OVER ( ) – function is used to specify which column to be considered while generating a row no. for the
row of the result set.

DISTNCT VALUES. The following example generates a distinct material number. The KOTN203 table has
a bonus number and material cardinality [1:N].

A USEFUL TRICK: When our data duplicates, we can eliminate the duplicating data by writing return
row_number = ‘1’ and showcasing the every unique row. For example let’s assume that we want to showcase the
every unique bonus buy row.

**Distinct
et_data = select bbynr, matnr from
(select ROW_NUMBER( ) over( partition by "BBYNR" ) AS RN1, * from kotn203 )
where RN1 = 1 and mandt = session_context( 'CLIENT' );

RANK( )- The RANK function returns duplicate values in the ranking sequence when there are ties between
values and the next rankings are skipped.
et_sort_data = select bbynr, matnr , werks , vkorg , vtweg ,
ROW_NUMBER( ) over( partition by "BBYNR" ORDER BY MATNR ASC ) AS ROW_ID,
RANK( ) over( partition by "BBYNR" ORDER BY MATNR ASC ) AS RANK_ID,
from kotn203 where mandt = session_context( 'CLIENT' );
DENSE_RANK( )- The DENSE_RANK function performs the same ranking operation as the RANK function,
except that rank numbering does not skip when ties are found.

et_sort_data = select bbynr, matnr, werks,vkorg,vtweg,


ROW_NUMBER( ) over( partition by "BBYNR" ORDER BY MATNR ASC ) AS ROW_ID,
DENSE_RANK ( ) over( partition by "BBYNR" ORDER BY MATNR ASC ) AS DRANK_ID
from kotn203 where mandt = session_context( 'CLIENT' );

You might also like