SQL Cod
SQL Cod
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun .
TYPES: BEGIN OF ty_students,
student_id TYPE int4,
student_name TYPE c LENGTH 40,
dep_name TYPE c LENGTH 40,
score TYPE int4,
END OF ty_students.
DATA: lt_students TYPE TABLE OF ty_students WITH DEFAULT KEY.
METHODS: constructor.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
METHOD if_oo_adt_classrun~main.
SELECT FROM @lt_students AS lt_students
FIELDS student_id,
student_name,
dep_name,
score,
" note: If partition by is not mentioned whole data is consider as single result set
SUM( score ) OVER( ) AS total_score,
MAX( score ) OVER( ) AS maximum_score,
MIN( score ) OVER( ) AS minimum_score,
CAST( AVG( score ) OVER( ) AS INT4 ) AS average_score,
SUM( score ) OVER( ORDER BY dep_name ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT
ROW ) AS cumulative_sum,
OUTPUT: