Skip to Content
0

hana xsds count not working

Dec 16, 2016 at 08:00 PM

134

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Sergio Guerrero Dec 16, 2016 at 08:07 PM
0

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

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

Share
10 |10000 characters needed characters left characters exceeded
Giri Sreerangam Jan 13, 2017 at 05:43 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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 ?

0