Skip to Content
Aug 20, 2019 at 02:17 PM

Counting associated entities using CDS

2738 Views Last edit Aug 20, 2019 at 02:27 PM 2 rev


Is there a way to count the number of associated entities using CDS? Let's say I'd like to display the number of books written by a particular author:

  entity Books {
    key ID : Integer;
    title  : localized String;
    author : Association to Authors;

  entity Authors {
    key ID : Integer;
    name   : String;
    books  : Association to many Books on = $self;
    numberOfBooks : Integer;

I tried something like count(books) as numberOfBooks but it's not supported :-)