EZP-23129: fixed: replace DISTINCT with GROUP BY