Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

hana xsds count not working

SergioG_TX
Active Contributor
0 Kudos

hello community -

I am following this blog : https://blogs.sap.com/2015/03/26/xs-data-services-building-cds-queries/ and i am able to get the aggregation sum, avg, etc... i am looking to implement a count but it is not working for me... again, the sum, avg functions work but count does not..

is this a bug?

my code:

var output = myTable.$query()

.$where(<MY_WHERE_CONDITION>)

.$aggregate(<MY_AGG_COLS>)

.$addFields({ COL_SUM: table.COL_SUM.$sum(),

COL_AVG: table.COL_SUM.$avg(),

COL_COUNT: table.COL_SUM.$count()

}).$execute();

then, the output....

{

COL_SUM : <CORRECT_SUM>,

COL_AVG: <CORRECT_AVG>,

COL_COUNT : { }

}

why is the COL_COUNT returning {} instead of an actual count (int) - i have tried w different columns without any luck. any help is appreciated -

thank you

3 REPLIES 3

SergioG_TX
Active Contributor
0 Kudos

just to add - all these functions work fine: $min(), $max(), $avg(), $sum()...

however $count() does not ... very strange - this is a SP11 system

former_member187794
Participant
0 Kudos

not sure, what can be the reason. but it did not work for me as well. I have used a length function to get the count of a column

- Regards/Giri

0 Kudos

the length function for the result of the query execution? that would give you the number of rows, not the column count... or what do you mean by ... you used the length function to get the count of a column ?