Hello, i am trying to sum rows of table after group by, let me explain my problem with an example:
example: from table below....
1. i need to calculate total expenses by name, dept. I can do this with group by , simple and easy.
by name:
select e.Employee name , sum(expenses) from Employee e group by Employee name
by dept:
select e.Employee name , sum(expenses) from Employee e group by dept
2. this is where i am struggling with query dsl. i need to calculate total expenses when grouped by name or dept. with native sql i can do below
select sum(employeeExpense) from (select e.Employee name , sum(expenses) as employeeExpense from Employee e group by Employee name)X
I am stuck with step 2 to solve that problem using query dsl, is there a way to do this in query dsl ?
Employee:
Employee name
|
expenses
|
dept
|
John
|
200
|
1
|
Karen
|
300
|
1
|
Jessica
|
500
|
2
|
John
|
100
|
1
|
karen
|
50
|
1
|
thanks for your time.