Hi,
after digging for more information, I have found a SAP Note that describes a pretty close problem, that a SELECT DISTINCT from a CDS can cause a SQL Error. The reason is the CLIENT field.
After a closer look into the DDL file of the CDS entity, I have noticed that
the generated annotation from the ADT wizard @ClientDependent was from me commented.
Reviewing again the help for it, this time with a closer look at the default values, has brought me the light: the CLIENT field was automatically in the select list included, due to commented annotation.
The solution came naturally to me: removing the comments to the annotation and setting his value to False like this
@ClientDependent: false
Regards,
Attila
P.S: as usual, every solution to a problem stays in details