pcyuen98 / covidAngular

0 stars 0 forks source link

KT-Query using PARTITION BY #18

Closed nadizeq closed 3 years ago

nadizeq commented 3 years ago

The function of PARTITION BY clause is to divide the result set into partitions and perform computation on each subset of partitioned data.

The syntax of PARTITION BY clause: window_function ( expression ) OVER ( PARTITION BY expression1, expression2, ... order_clause frame_clause )

An example of it which returns the employee's salary and the average salary of the employee department: SELECT first_name, last_name, department_id, ROUND(AVG(salary) OVER ( PARTITION BY department_id )) avg_department_salary FROM employees;

Resource:

  1. https://www.sqltutorial.org/sql-window-functions/sql-partition-by/
pcyuen98 commented 3 years ago

If return of the sql needs to be customize as per example above. Then it needs a customized bean or solution as below

https://stackoverflow.com/questions/33701905/springdatajpa-custom-data-mapping-with-native-query