cancel
Showing results for 
Search instead for 
Did you mean: 

Add (summation) columns in Select query based on already summed columns in QUERY

former_member478603
Participant
0 Kudos

I want to add all the columns and rows for this table PMCO

e.g : add all 16 fields in this table for single order. How can i achieve it. I thought the below way sum all the columns first and then use temporary variable saying add( w + w1). but it says that variables are not available till runtime. MAy if i can achieve it in single query. IF not then i will fetch the required data and use business logic to add it.

Accepted Solutions (1)

Accepted Solutions (1)

former_member14709
Contributor

Hi Madhuri,

I can think of 2 possible ways for your requirement:

1) You can build a CDS in a way similar to how you are you are building your query now in above screenshot. And you can build another CDS/select query on top of first CDS to sum up the summed columns.

2) You could create a CDS Custom entity and write your business logic in the respective query implementation class. Although you can not use cds custom entity as a data source in other CDS/select queries, so you can go with this way if you want to expose this calculation as an oData entity.

Hope this helps.

Thanks,

Aman Garg

Answers (0)